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

For Loops in PHP Forum

View Course » View Exercise

652 points
558bd0529376766a6200038c_852780057
Submitted by
Cosmin Barsan
over 2 years ago

7/7 The code is correct but I don't know why I get this error.

<?php
$yardlines = array("The 50... ", "the 40... ",
"the 30... ", "the 20... ", "the 10... ");
foreach($yardlines as $item) {
echo $item;
}
echo "touchdown!";
}
?>
This is the code and this is the error:

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


0 votes

permalink

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


  //echo "touchdown!";
  ?>

429 points
11e8f1bdb8a14138cc318391c9942b8b?s=140&d=retro
Submitted by
darkflashstar
over 2 years ago


0 votes

permalink

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

this is what I put and it works for me..

847 points
57067220083510758e3589b2e4e493c6?s=140&d=retro
Submitted by
Nathaniel James
over 2 years ago


0 votes

permalink

u used an extra " } " , remove it.
.
it should be:
foreach( $yardlines as $y ){
echo $y;
echo"touchdown!"; }

266 points
Picture
Submitted by
DrawThings Designin
over 2 years ago


-1 votes

permalink

Check This One

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

88 points
C64f9d4e82d7d1db9d7070ff1c343068?s=140&d=retro
Submitted by
SM Danish
over 2 years ago

4 Comments

558bd0529376766a6200038c_852780057 Cosmin Barsan over 2 years ago

Same....

C64f9d4e82d7d1db9d7070ff1c343068?s=140&d=retro SM Danish over 2 years ago

No ... you echo "touchdown!";

558bd0529376766a6200038c_852780057 Cosmin Barsan over 2 years ago

Yea, worked now, ty

C64f9d4e82d7d1db9d7070ff1c343068?s=140&d=retro SM Danish over 2 years ago

g8