This forum is now read-only. Please use our new forums at

For Loops in PHP Forum

View Course » View Exercise

662 points
Submitted by
over 3 years ago

says that I haven't echoed 'the 10'

What's wrong?

    $yardlines = array("The 50... ", "the 40... ",
    "the 30... ", "the 20... ", "the 10... ");
    // Write your foreach loop below this line
    foreach ($yardlines as $touchdown){

    // Write your foreach loop above this line
    echo $touchdown;

What's wrong it says that I haven't echoed 'the 10'

2 votes


I did it the same way you did at first but I changed the code.

Calling each item in the array "$yardlines" as $yards. allows you to break up each item of the array. and echo each item individually as $yards.

Lastly, If you include "echo "touchdown!"; inside of the loop ( "}" ) it will repeat after it displays every individual item for $yards, (example.. the 50... touchdown! the 40... touchdown!) Leaving the default echo "touchdown!"; statement outside of the loop ( "}" ) adds the "touchdown!" to the very end of the string. hopefully that helps you.

$yardlines = array("The 50... ", "the 40... ",
"the 30... ", "the 20... ", "the 10... ");
  foreach ($yardlines as $yards) {
 echo $yards;
echo "touchdown!"; ?>

236 points
Submitted by
over 3 years ago


55df2afa95e3787b9200005e_359368177 Judy over 3 years ago

That's a much more thorough explanation than mine, I'll have to up my game a bit around here. :)

05cdc9af227e3401ea08ddc8638f2352?s=140&d=retro DeShoun over 3 years ago

No need to worry about me, I'm really just starting programming. I've been doing it for a few months so my game isn't strong yet.

52a35f517c82ca6532002608_138451395 LePwner over 3 years ago

Anyone of you know anything about PHP?

Picture Willamis Dilermando over 3 years ago

Muito obrigado! me ajudou bastante! Consegui sair dessa lição!

0 votes


It's looking for this line that was in the default code:

echo "touchdown!";

I'm curious why you chose to call each yardline $touchdown -- maybe it depends on how much of a football fan you are. Anyway, the name doesn't matter but it does make it more confusing than necessary.

3691 points
Submitted by
over 3 years ago

1 Comment

512ec2a24ec86e394a0052cd_456574260 Adam Kite almost 3 years ago

Some of us are not American you know lol. I am from the UK and i have no clue about American Football (Football in your terms).