For Loop In PHP
The for loop statement
The for statement is used when you know how many times you want to execute a statement or a block of statements.

Syntax
for (initialization; condition; increment) {
code to be executed;
}
Parameters:
- initialization — it is used to initialize the counter variables, and evaluated once unconditionally before the first execution of the body of the loop.
- condition — in the beginning of each iteration, condition is evaluated. If it evaluates to true, the loop continues and the nested statements are executed. If it evaluates to false, the execution of the loop ends.
- increment — it updates the loop counter with a new value. It is evaluate at the end of each iteration.
Example 1 : Print the numbers from 0 to 10
<?php
for ($i = 0; $i <= 20; $i++) {
echo "The number is: $i <br>";
}
?>
Output :
The number is 1
The number is 2
.
.
The number id 20
Series:
PHP Tutorials Hub
