How to use while loop statement in php?

Answer:

simple code example:

<?

while ($a < 10 ) {

echo "$a, ";

$a++;

}

echo "Finished";

?>

Will output,

1, 2, 3, 4, 5, 6, 7, 8, 9, Finished

this will run through the loop WHILE $a is less than 10, outputting the value of $a to the screen.

once $a = 10 then the loop will end and continue on with the rest of the script

First answer by Pool-king. Last edit by Pool-king. Contributor trust: 1 [recommend contributor recommended]. Question popularity: 1 [recommend question].