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

For Loops in PHP Forum

View Course » View Exercise

1314 points
Picture
Submitted by
Michael Warren
over 4 years ago

CODE WILL NOT PASS... PLEASE ASSIST WHEN TIME PERMITS. TY

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

OUTPUT
The 50...

the 40...

the 30...

the 20...

the 10...

touchdown!

ERROR:
Oops, try again! It looks like your loop didn't echo 'the 10... '.


5 votes

permalink

As there is not a logical or detailed reason why the code is working yet will not allow the code to pass, it just reminds me of Video Games. This is such an innovative concept and the little bugs are all being worked out but let me say, CODECADEMY.COM has done an AMAZING job!
Oh, Back to the resolution: The "Counter || Reverse Checking Code was looking for print despite the instructions on the left advising to echo... It's all good, It's all problem solving anyway!

<?php
$yardlines = array("The 50... ", "the 40... ",
"the 30... ", "the 20... ", "the 10... ");
// Write your foreach loop below this line
foreach ($yardlines as $downs) {
print $downs;
}
// Write your foreach loop above this line
echo "touchdown!";
?>
Congratulations, you've finished this section!

1314 points
Picture
Submitted by
Michael Warren
over 4 years ago


0 votes

permalink

On CHROME version 27 this worked?:

foreach ($yardlines as $yards) {
echo $yards;

    // Write your foreach loop above this line
    echo "touchdown!";
    }

477 points
Bc7b10e58d41c658e29632f4ca52311c?s=140&d=retro
Submitted by
Perry
about 4 years ago