The for Loop
The example below displays the numbers from 0 to 5:
for ($a = 0; $a < 6; $a++) {
echo "Value of a : ". $a . "<br />";
}
for ($a = 0; $a < 6; $a++) {
echo "Value of a : ". $a . "<br />";
}
Result:
The for loop in the example above first sets the variable $a to 0, then checks for the condition ($a < 6). If the condition is true, it runs the code. After that, it increments $a ($a++).
No comments:
Post a Comment