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 trialVictoria Loisi
7,070 PointsInside of your foreach loop echo each of the flavors to the screen.
Hi there, I cannot understand what I actually need to do. This is the code I do have and it does print the flavors to the screen:
<?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 $value){
echo $value['name'];
}
?>
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! It really doesn't like that you've typed AS
instead of as
. In fact, I'm not sure why it passes the first step in all caps, but it will not pass the second step in all caps. Make that teensy change and give it another shot!
Raman Matthew
13,286 PointsHi! here is the code which will work
foreach($flavors as $item) { echo $item['name'] . "<br />\n"; }
Victoria Loisi
7,070 PointsVictoria Loisi
7,070 PointsThank you! I've remember one of the videos typing AS in all caps, but that was it! Thank you!!