July 24, 2017

Core PHP: The while Loop (5.5)

The while Loop

The example below first sets a variable $i to one ($i = 1). Then, the while loop runs as long as $i is less than seven ($i < 7). $i will increase by one each time the loop runs ($i++):
$i = 1;
while ($i < 7) {
  echo "The value is $i <br />";
  $i++;
}

This produces the following result:
Example: Loop

No comments:

Post a Comment