The for statement has three parameters.

  1. The first parameter is for initializing variables
  2. The second parameter holds the condition
  3. The third parameter contains any increments required to implement the loop.

If more than one variable is included in either the initialization or the increment section, then they should be separated by commas. The condition must evaluate to true or false.


The following example prints the text "Hello World!" five times:

<html>
<body>
<?php
for ($i=1; $i<=5; $i++)
{
echo "Hello World!<br />";
}
?>
</body>
</html>

(from w3schools.com)

Foreach

Table of Contents