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

PHP Build a Simple PHP Application Listing Inventory Items Introducing Arrays

Alec Jones
Alec Jones
5,510 Points

Changing Static Text???

I have my foreach command. But when it asks me to change the static text to show the value of the array in consideration of the foreach command. I am not sure what it means. (The static text is the echo "AB";)

<?php

$letters = array("D", "G", "L", );

echo "My favorite ";

echo count($letters);

echo " letters are these: ";

foreach($letters as $letter){ echo $letter; }

echo "AB";

echo ".";

?>

1 Answer

Richmond Lauman
Richmond Lauman
28,793 Points

Hi Alec.

They want you to change the echo "AB"; statement so it is outputting $letter values from the $letters array each time the loop runs. You almost have it. In the task you did previous to this one it asked you to place the closing curly bracket for your loop between the second last and last echo statements. Yours is just before the second last. Once you hace done that you will have two echo statements in the loop. You only need the one that will give values from the array.