I am getting error when I upload on shared hosting but in local computer works fine.
My code is below:
<?php
$arr = ["one","two","three"];
echo $arr[0];
?>
current error:
Parse error: syntax error, unexpected '[' in /home/jacky/public_html/test.php on line 2
I think your PHP version
is under 5.4
so you can use []
.
You have to use this:
$arr = array("one","two","three");
echo $arr[0];
For more information see: http://php.net/manual/en/language.types.array.php