Whats wrong with this?

0 Kumi Festus · October 7, 2014
<?php
  $food = array("Healthy"=>
                   array("vegetables","Salad","Pasta"),
                "Unhealthy"=>
                    array("ice cream","pizza"),
                "Medicinal"=>
                    array("Garlic","Ginger","Not Sure"));
 
echo "Some Foods I know are:".$food[Healthy][2].",".$food[Unhealthy][0]." and " .$food[Medicinal][0];
?>


Output Below

Notice: Use of undefined constant Healthy - assumed 'Healthy' in C:\xampp\htdocs\BMNetwork\files.php on line 15

Notice: Use of undefined constant Unhealthy - assumed 'Unhealthy' in C:\xampp\htdocs\BMNetwork\files.php on line 15

Notice: Use of undefined constant Medicinal - assumed 'Medicinal' in C:\xampp\htdocs\BMNetwork\files.php on line 15
Some Foods I know are Pasta,ice cream and Garlic .

Post a Reply

Replies

Oldest  Newest  Rating
0 Mayowa Olaitan · October 17, 2014
<?php
  $food = array("Healthy"=>
                   array("vegetables","Salad","Pasta"),
                "Unhealthy"=>
                    array("ice cream","pizza"),
                "Medicinal"=>
                    array("Garlic","Ginger","Not Sure"));
 
echo "Some Foods I know are:".$food['Healthy'][2].",".$food['Unhealthy'][0]." and " .$food['Medicinal'][0];
 
?>

no quote when declaring your array.
  • 1

PHP

107,008 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators