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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![moath alqutoob](https://secure.gravatar.com/avatar/6dba99da57ed109c5e23c13a95ae325a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
moath alqutoob
2,450 Pointsi cant solve this
he 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”.
<?php
echo "My favorite "; echo "2"; echo " letters are these: "; echo "AB"; echo ".";
?>
<?php
$letters=array("D","G","L");
echo "My favorite ";
echo count($letters);
echo " letters are these: ";
foreach($letters as $letter) {
?>
echo "AB"; }
echo ".";
?>
1 Answer
![Grace Kelly](https://uploads.teamtreehouse.com/production/profile-photos/651222/micro_IMG_20150725_181534_4.jpg)
Grace Kelly
33,990 PointsHi moath, this step of the code challenge asks you to contain echo "AB"; within a foreach loop. You have the code correct however you are closing it of with "?>" before the foreach loop has finished, which means any php after that closing tag will not execute until you open it up again with "<?php". To solve this, simply remove the "?>" and it should work, like so:
<?php
foreach($letters as $letter) {
echo "AB";
}
echo ".";
?>
hope this helps!!