PHP While Loop Statements

Colin Viebrock, CC BY-SA 4.0, via Wikimedia Commons
A while loop executes a certain block of code until a particular condition is no longer true. Syntax
<?php
while(conditional)
{
//code block
}
?>
A while loop says as long as this condition inside the brackets () is true, keep executing the code block inside of {}.
Example
<?php
$i=0;
while($i<10)
{
echo $i;
echo "<br>";
echo $i++;
}
?>
Result
Your while loop should have inside it 1) a counter and 2) a way of increasing the counter.
Otherwise, your loop will keep repeating forever without a way to end.




