For Loop in PHP


Prev Tutorial Next Tutorial

For Loop in PHP

The for loop is used when you know in advance how many times the script should run. In php for loops execute a block of code specified number of times.

Syntax

for (initilation; condition; increment/decrement)
{
    code to be executed;
}

Example of for Loop in PHP

<?php

for ($i = 0; $i <= 10; $i++) 
{
    echo "$i <br>";
}

?>

Output

0 1 2 3 4 5 6 7 8 9 10

Prev Tutorial Next Tutorial

Download Projects

Yahoo Advertisements
Free Classified Site – Bedpage

Adsense Ads Advertisements