PHP For Loops

The for loop is simply a while loop with a bit more code added to it. The common tasks that are covered by a for loop are:
  • Set a counter variable to some initial value.
  • Check to see if the conditional statement is true.
  • Execute the code within the loop.
  • Increment a counter at the end of each iteration through the loop.
Syntax
1
2
3
4
   for (init; condition; increment)
    {
    code to be executed;
    }
Parameters:
  • init: Mostly used to set a counter (but can be any code to be executed once at the beginning of the loop)
  • condition: Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
  • increment: Mostly used to increment a counter (but can be any code to be executed at the end of the loop)
PHP Arrays
PHP If...Else Statements
PHP Forms and User Input
PHP Functions