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

For Loops in PHP Forum

View Course » View Exercise

148 points
Picture
Submitted by
Harish Gadde
over 4 years ago

for loop 10's up to hundred

for($i = 0; $i < 11; $i++)

  {

        $i = $i + 10;

        echo $i; 

  }

4 votes

permalink

 <?php
   // Write your for loop below!
      for ($i = 10; $i <= 100; $i = $i + 10){
      echo "<br> Resultado: $i";
    }
 ?>

115 points
52292d75abf8213ea3001798_66361957
Submitted by
Elkin Blanchar Mejia
over 4 years ago

2 Comments

52292d75abf8213ea3001798_66361957 Elkin Blanchar Mejia over 4 years ago

Try this !!

5246c1b2f10c60f324002e4c_482475389 Yee Joo about 4 years ago

can't =(


0 votes

permalink

this work too... but is not the correct request for this excercise!!

<?php
// Write your for loop below!
for($i=1; $i<=10; $i++){
$result = $i * 10;
echo " resultado: $result";
}
?>

115 points
52292d75abf8213ea3001798_66361957
Submitted by
Elkin Blanchar Mejia
over 4 years ago

1 Comment

52292d75abf8213ea3001798_66361957 Elkin Blanchar Mejia over 4 years ago

Excuse me my english, jejeje but i try... sorry.. Im from Colombian!! be happy coding !!


0 votes

permalink

I had this problem because I failed to realize you don't semi-colon the last parameter before the closing parenthesis

WHAT I HAD
for ( $i = 10; $i <= 100; $i = $i + 10;)

WHAT YOU'RE SUPPOSED TO HAVE
for ( $i = 10; $i <= 100; $i = $i + 10)

312 points
5233fb9680ff3344b5002e83_891682010
Submitted by
Shane Stouts
about 4 years ago