foreach loop echo

Whenever I try to input the following code at the end of this message, I get an error message saying that I am not echoing 'The 50… ’ or I am not echoing 'The 10… ’ even though I see all the array values on screen

<?php $yardlines = array( 'The 50...', 'the 40... ', 'the 30... ', 'the 20... ', 'the 10...' ); foreach($yardlines as $item) { echo ($item); } ?>

What is the EXACT error message?

OK, I just re-read your question and misread it.

The script works, but when you add something then it flames out on you?

Give the error like Kevin states and the script the way it is written when the error occurs.

Here is my EXACT error message.

“Oops, try again. It looks like your loop didn’t echo 'the 10… '.”

Here are the EXACT programming instructions for me

“On line 8[$yardlines = array('The 50… ', 'the 40… ',][/i][/i], there’s an array named $yardlines. Write a foreach loop that iterates over the array and echos each element to the page.”

We asked you for the exact ERROR message you got.

we need the php error. do you get the message if you use a for loop?

Richei, the programming tutorial at http://www.codecademy.com/courses/web-beginner-en-L83Do/0/7?curriculum_id=5124ef4c78d510dd89003eb8 does not give me a PHP error message, just the following generalized ERROR message

Oops, try again. It looks like your loop didn’t echo 'The 50… '.

There is nothing wrong with it.

[php]

<?php $yardlines = array("The 50... ", "the 40... ", "the 30... ", "the 20... ", "the 10... "); // Write your foreach loop below this line foreach($yardlines as $item) { echo ($item); }

    // Write your foreach loop above this line
    echo "touchdown!";
  ?>
</p>
[/php]

Kevin Rubio, then perhaps there is something wrong with the computer programming excercise itself. It could be an error on the website’s behalf.

No, I updated your link and it works there too.

I have to agree, theres nothing wrong with the loop.

Sponsor our Newsletter | Privacy Policy | Terms of Service