When i write code i have to use loops e.g.
$six = 6;
for ($i = $six; $i > 1; $i--) {
echo $i."<br>";
}
outputs
6
5
4
3
2
i need it to output 1 as well i know i can do for ($i = 6; $i >= 1; $i--)
or
for ($i = $six+1; $i > 1; $i--) in evaluation but its confusing so muchg!
in fact i always confused when using for statement.
EDIT: its confusing because i dont like to think backwards.. id like to run loop not while condition $six > 1 is true, but rather before condition like $six = 1 is meet.
the opposite way i guess
loop_before ($six==1) {
echo $six.<br />;
$six--;
}
well even this one wont output 654321… guess i just need to go back to school.
got to do
loop_before ($six<1) {
echo $six.<br />;
$six--;
}
This confusion may not be only for
for()statement but for other types of loop. You can use$six >= 1or$six > 0Example 1
Example 2
Example 3
Lastly you might decide not to even use any default PHP loop
They would all return the same thing