-2
<?php
array $food= array('healthy'=>
array('Salad','Vege',Pasta'),
'unhealthy'=>   
array('pizza','icecream'));
echo $food['unhealthy'][1];
?> 

i am writing this code but getting this error on browser:

error : Parse error: syntax error, unexpected '$food' (T_VARIABLE), expecting '(' in C:\xampp\htdocs\foreach.php on line 2

David Makogon
  • 69,407
  • 21
  • 141
  • 189

1 Answers1

0

Remove array at the starting and also there is missing single quote before Pasta.

Try this

<?php

    $food = array(
              'healthy'=> array('Salad', 'Vege', 'Pasta'),
              'unhealthy'=> array('pizza', 'icecream')
            );

    echo $food['unhealthy'][1];

?>
Rizier123
  • 58,877
  • 16
  • 101
  • 156
Manish
  • 3,443
  • 1
  • 21
  • 24