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

For Loops in PHP Forum

View Course » View Exercise

661 points
Submitted by
about 5 years ago

Answer for "All On Your Own!" exercise.

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

The 50... the 40... the 30... the 20... the 10... touchdown!

4 votes


Wow...burst my brains on that last one! so why did we need that last echo/print at the end??

it was not specified in the instructions but it seems that after the loop, as long as you put in an echo/print it will accept your answer, though your answer was being displayed correctly.. because i put

print $touchdown;

and though i had no variable named "$touchdown" it still accepted...guys you need to review this lesson (MODS)

250 points
Submitted by
Uriahs Victor
almost 5 years ago


Picture Riyaz Ibrahim over 4 years ago

I also got confused. i tried the exercise without the $touchdown; part assuming that I don't need it but I was receiving the same stupid error saying I didn't echo the 10.... and then I searched the forum and found the answer. I think the mods should review the exercise. Thanks for the answer

51d6f8ae52f86340ea01f07b_989590132 Lisvem over 4 years ago

It doesn't work as it should. Please mods, review!!!

Dfb6751d1392a90999c9155290c44b09?s=140&d=retro ronniebanks6684 over 4 years ago

This doesn't make any sense...what made you decide to do it this way....The course isn't clear, I spend more time on this forum than completing the exercises!

E00fdb994e30792754a0c99a73472084?s=140&d=retro Tim over 4 years ago

Yes it was confusing at the end. I ended up putting the curly brace after "echo "Touchdown!!". Still took my answer though. Thank you for this.