This loop showing empty page i want to run it til -60.
for($i = 6; $i <= -60; $i-=6){
echo $i; echo '</br>';
}
Use >=
, not <=
:
for($i = 6; $i >= -60; $i-=6){
echo $i; echo '</br>';
}
Note that >=
is greater than or equal, and <=
is less than or equal.
Your requirement and code are contradictory. Starting from $i = 6
and then check if $i
is less than or equal to -60 which is false. Rewrite your code like this.
for($i = 6; $i >= -60; $i-=6){
echo $i; echo '</br>';
}
Output as expected:
6
0
-6
-12
-18
-24
-30
-36
-42
-48
-54
-60
People are usually hard on newbies, but we've gotta be patient, we were all newbies once. And I think OP is in need of something more than just answer to his [trivial] question.
echo
statements on the same line (and absence of spaces where they are needed).2.3. Lines
There MUST NOT be more than one statement per line.