Basic Syntax
while (statement)
{
//code to be executed
}
Explanation
The statement in ‘while (statement)’ needs to be an expression that can be either false or true.
If the statement is true, the code in the while loop will be executed until the statement happens to be false.
Example
<html><body>
<?php
$i = 0;
while ($i<5)
{
echo '$i = '.$i.'<br />';
++$i;
}
?>
</body></html>
Output:
$i = 0 $i = 1 $i = 2 $i = 3 $i = 4
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.