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

Google Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements