PHP Tutorial
The for statement is used when you know how many times you want to execute a statement or a block of statements.
The for loop - Loops through a block of code a specified number of times.
for (init counter; test counter; increment counter) {
code to be executed for each iteration;
}
Let's put these syntax into real use.
<?php
for ($x = 10; $x <= 20; $x++) {
echo "Number = $x <br>";
}
?>
This will produce the following result −
Number = 10
Number = 11
Number = 12
Number = 13
Number = 14
Number = 15
Number = 16
Number = 17
Number = 18
Number = 19
Number = 20