PHP For Loop

PHP for loop can be used through a set of codes for the specified number of times.

Syntax

<?php
for(initialization; condition; increment/decrement){  
//code to be executed  
}  
?>

Example

The example below return the numbers from 0 to 5:

<?php
for ($a = 0; $a <= 5; $a++) {
    echo "The number is: $a 
"; } ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

*