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

For Loops in PHP Forum

View Course » View Exercise

524 points
Submitted by
Louis Bond
over 4 years ago

Seems a little silly

Here is the section of code that seems silly
foreach($yardlines as $yard) {
echo "$yard";

Why is this the only solution? I was running into a problem were I was told that I hadn't passed "the 10..." to the page when I had it as below
foreach($yardlines as $yard) {
echo <p>"$yard"</p>;

I say this is silly because not only was "The 10..." visible on the preview page, but it seems that railroading programming would be counter-productive to the field.

0 votes


To add words (or strings), to a variable, in PHP.

  1. All strings should be written inside quotation marks
  2. To join any variables need put a dot

    foreach($yardlines as $yard) {
    echo "string...".$yard.'... other string';

538 points
Submitted by
about 4 years ago

-1 votes


I don't know why but it took this code:
foreach($yardlines as $touchdown) {

echo $touchdown; }
//write foreach above this line
echo "$touchdown!";

with this it will show all upto the 10... + touchdown! press submit and its a success.
I think so their prebuild code for this program by codecadamy is fixed by touchdown , it can be by mistake or intentionally.. njoy.

66 points
Submitted by
Jaspreet Singh
over 4 years ago