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

What is wrong here, all seems correct but won't let me pass????

Why won't this pass?


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

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


1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there, koltton fox! You're doing great, but you have a bit of a typo. But instead of it causing an error it causes a bit of an unexpected result. If you check the "Preview" you should see the problem. It doesn't contain "ACME", but only "E". The culprit is an extraneous semicolon at the beginning of your for loop.

You wrote:

 foreach ($letters as $value); {

But you meant to write:

 foreach ($letters as $value) {  // Note the removal of the semicolon between the closed parenthesis and open curly brace

Hope this helps! :sparkles: