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 trialJeff Wolfram
10,490 PointsI dont understand what it is asking me to do.
It says 3rd and 4th echo command. I only have two up to this point. I dont understand what it is asking me to do right now. The code block below displays a list of two letters from the Latin alphabet using echo statements. But these two letters are NOT my favorite letters! In this code challenge, we’ll change this block of code to display my real favorite letters. We’ll also modify it to use an array so that it’s easier to add a new letter in the future. Before the first echo statement, create an array called letters. Give that letters array one element with a value of “D”. This i s the code I have so far. '''php <?php $letters = array("D", "G", "L") ?> <?php echo "My favorite " . count($letters) . " letters are these:\n" ; foreach($letters as $letter){ echo $letter . "\n"; } ?> '''
3 Answers
geoffrey
28,736 PointsI've just followed again the code challenge and once arrived at this step, I had indeed 5 echo commands displayed.
Here is the solution till step 6. Check and see what's wrong with you code as I can't see clearly from your code.
<?php
$letters =array("D","G","L");
echo "My favorite ";
echo count($letters);
echo " letters are these: ";
foreach($letters as $letter){
echo $letter;
}
echo ".";
?>
NOREST GOMBIRO
15,463 PointsTHANKS TO EVERYONE WHO CONTRIBUTED TO OUR FORUM
Jeff Wolfram
10,490 PointsOkay. I see what I did. I just rewrote the code and skipped ahead and just didn't follow the directions. Doh! Thanks!