vipsa Posted January 8, 2013 Share Posted January 8, 2013 I am a complete beginner so I need help. I have the following code: <code> $foodprices = array("vegetables"=>array("Tomatoes"=>1.00, "Beet"=>20.5, "Onions"=>3.5), "Meat"=>array("Skaap"=>20.5, "Bees"=>30.5)); var_dump($foodprices); foreach($foodprices as $category) { echo "The current category is $category";//print the category foreach($category as $food => $price) { echo "<br>The price of {$food} is {$price}";//print each item and its price } } </code> I would like to print the category names as well so how do I print the key values of a multidimensional array please. Any help is appreciated Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted January 8, 2013 Share Posted January 8, 2013 You are printing the category.... echo "The current category is $category";//print the category Quote Link to comment Share on other sites More sharing options...
haku Posted January 8, 2013 Share Posted January 8, 2013 You are already printing the category name. Since you seem to want something else, give us an example of the output you are trying to achieve. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.