while
The while loop is the simplest looping structure but sometimes the least compact to use. The while loop repeats one or more statements-the loop body-as long as a condition remains true. The condition is checked first, then the loop body is executed. So, the loop never executes if the condition isn't initially true. Just as in the if statement, more than one statement can be placed in braces to form the loop body.
The following fragment illustrates the while statement by printing out the integers from 1 to 10 separated by a space character:
$counter = 1;
while ($counter < 11)
{
echo $counter;
echo " ";
// Add one to $counter
$counter++;
}