0

I tried to define an simple array in php, and I got an "unexpected '[' error message.

Code:

<?php
      $days = ["Mon","Tue","Wed","Thu","Fri"];
      echo "Value at index 1 is ". $days[1];
?>

while using the $days = array("Mon","Tue","Wed","Thu","Fri"); works fine

abedzantout
  • 802
  • 4
  • 15
  • 28

1 Answers1

3

If your version of PHP is < 5.4 you cannot use [] to define an array. Create a page that contains:

<?php phpinfo() ?> 

and see what version that says. Alternatively, if you have shell access to the server you're working on, typ this on the command line:

`php -v`
Jeffwa
  • 1,143
  • 10
  • 12