| While loop is very useful and mostly use to fetch rows from the databases. It loops back till the condition is true | |
| Simple while $test =1; while ($test <= 10 ) { if (($test % 2)==0){ echo " $test is divisible by 2 <br>";} if (($test % 3)==0){ echo " $test is divisible by 3 <br>";} $test++ ; } ?> |
![]() |
| <?php //get the current date in number of seconds $currentDate = time(); //print some text explaining the output print("Days left before Monday:\n"); print("<ol>\n"); while(date("l", $currentDate) != "Monday") { //print day name print("<li>" . date("l", $currentDate) . "</li>\n"); //add 24 hours to currentDate $currentDate += (60 * 60 * 24); } print("</ol>\n"); ?> |
![]() |