Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Introducing Arrays

PHP help ?

Martin Guzman3,019 Build a Basic PHP Website Challenge Task 4 of 4

The original code was hard-coded to echo the letters "AC" instead of the contents of the $letters array. Replace the fourth echo statement with a foreach loop that prints each letter in the array. Bummer! We don't see 'ACME' in the output. Preview Get Help Reset Code Recheck work index.php ;

; 1 <?php 2 $letters = array ( "A", "C","M", "E"); 3 ​ 4 ​ 5 echo "Today's challenge is brought to you by the "; 6 echo count ($letters); 7 echo " letters: "; 8 foreach ($letters as $item){ 9

10 echo "<li>" . $item . "</li>"; 11

12 }; 13 echo "."; 14 ​ 15 ?> Career Resources

Get tips and resources on how to prepare for and find a new job in the industry. Treehouse for Mobile

Learn anytime and anywhere with Treehouse for iPad or Android. Download for free today. Student Perks

A collection of special discounts and exclusive offers available for Treehouse students. Treehouse BlogAbout TreehousePrivacy PolicyTerms & Conditions©2016 Treehouse Island, Inc.

index.php
<?php
$letters = array ( "A", "C","M", "E");


echo "Today's challenge is brought to you by the ";
echo count ($letters);
echo " letters: ";
foreach ($letters as $item){

  echo "<li>" . $item . "</li>";

};
echo ".";

?>

1 Answer

Geovanie Alvarez
Geovanie Alvarez
21,500 Points

Try this

<?php
$letters = array("A", "C", "M", "E");

echo "Today's challenge is brought to you by the ";
echo count($letters);
echo " letters: ";
foreach($letters as $item){
  echo $item;
}
echo ".";
?>