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

For Loops in PHP Forum

View Course » View Exercise

437 points
516dc09e8a1e8605a70018e9_485525991
Submitted by
Andrew
over 3 years ago

(ANSWERED) Did you replace the first blank with the keyword for?

I replaced the ___ with the keyword for and im still getting "Did you replace the first blank with the keyword for?"

Here is my code:

For Loops



<?php
// Echoes the first five even numbers
for ($i = 2; $i < 11; $i = $i + 2) {
echo $i;
}
// echoes 246810
?>

Before:

For Loops



<?php
// Echoes the first five even numbers
___ ($i = 2; $i < 11; $i = $i + 2) ___
echo $i;
___
?>

After:

For Loops



<?php
// Echoes the first five even numbers
for ($i = 2; $i < 11; $i = $i + 2) {
echo $i;
}
?>

Answered
Not sure what was wrong but it randomly worked...
For Loops
<?php
// Echoes the first five even numbers
for ($i = 2; $i < 11; $i = $i + 2) {
echo $i;
}
?>


2 votes

permalink

for($i = 2; $i < 11; $i = $i + 2) {
echo $i;
}
You put one space between for and "("

564 points
Picture
Submitted by
Gabriel Aquino Oliveira
over 3 years ago

1 Comment

Fbaf234270436c72387d16c9d3aee862?s=140&d=retro Samantha Ma about 2 years ago

thanks!


1 vote

permalink

<?php
// Echoes the first five even numbers
for ($i = 2; $i < 11; $i = $i + 2) {
echo $i;
}
// echoes 246810
?>

This works

555 points
55264f0651b887c2c70004d4_284732586
Submitted by
Usha
over 2 years ago