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 trial
Marcos Melone
5,220 PointsCreating the Products Array
The challenge of Creating the Array Products, I do not understand what I do, it seems simpleso challenge but I've tried several ways to do it and did not certoalguém can help me? My code:
<?php
$flavors = array();
$flavors [1]= "chocolate";
$flavors[2] = "vanila";
?> <p>Welcome to Ye Olde Ice Cream Shoppe. We sell <?php echo "2"; ?> flavors of ice cream.</p> <ul> <?php foreach($flavors as $flavors); {?> <li><?php echo $flavors; ?></li> <?php } ?> </ul>
1 Answer
Randy Hoyt
Treehouse Guest TeacherSo close.
- You have to capitalize the name of the flavors. It's "Chocolate" with a capital "C", not "chocolate." (And you have to spell Vanilla correctly.)
- You start with 0, not 1.
<?php
$flavors = array();
$flavors[0]= "Chocolate";
$flavors[1] = "Vanilla";
?>