Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVivek Gupta
501 Pointshelp me
help me
<?php
$flavors = array();
$flavors[] = array("name" => "Cookie Dough", "in_stock" => true);
$flavors[] = array("name" => "Vanilla", "in_stock" => false);
$flavors[] = array("name" => "Avocado Chocolate", "in_stock" => false);
$flavors[] = array("name" => "Bacon Me Crazy", "in_stock" => true);
$flavors[] = array("name" => "Strawberry", "in_stock" => false);
//add your code below this line
foreach($flavors as $flavors) {
//echo $flavors['name'] ;
}
?>
2 Answers
Christopher Debove
Courses Plus Student 18,373 PointsPlease... I already helped you this morning with a previous challenge, explaining all steps for you, and you didn't even said "thank you". If you really don't understand what you need to do, review the course and try what is explain to you in the workspace. You can't just take the answer we give to you and copy/paste them.
The second variable in your foreach loop must be different from your array variable, as it represents the value for each loop iteration, ex:
<?php
foreach ($flavors as $flavor) {
echo $flavor['name'];
}
?>
You can do the rest yourself
angelacarabelas
1,451 PointsThanks for the explanation, Christopher! That makes sense.