PHP for loop
PHP for loop run the code specified number of times.
SYNTAX
for(initialization; condition; increment)
{
// Code to be executed
}
PARAMETER
Name | Description | Required /Optional |
---|---|---|
Parameter | Initialize the loop counter value | |
Condition | If it condition evaluates to TRUE, the loop continues. If it condition evaluates to FALSE, the loop ends. | Required |
increment | Increment or Decrements the variable |
Example for PHP for loop
<?php
//Display 1 to 10 Number
for($n=1;$n<=10;$n++)
{
echo “Number = $n<br>”;
}
?>