Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    PHP for loop

    PHP for loop is very similar to a while loop in that it continues to process a block of code until a statement becomes false, and everything is defined in a single line.

    Syntax:

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

    php-for

    Example:

    <?php 
    for ($i=1; $i <= 5; $i++ ){ 
      echo "PHP for loop print $i times"."<br>";
    } 
    ?>

    Program Output:

    PHP for loop print 1 times
    
    PHP for loop print 2 times
    
    PHP for loop print 3 times
    
    PHP for loop print4 times
    
    PHP for loop print5 times


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.