Use do while to print day name in PHP
Description
The following code shows how to use do while to print day name.
Example
<?php//w ww .j ava 2s . c om
/*
** get the current date in number of seconds
*/
$currentDate = time();
//print some text explaining the output
print("Days left before next Friday:\n");
print("<ol>\n");
do
{
/*
** print day name
*/
print("<li>" . date("l", $currentDate) . "</li>\n");
/*
** add 24 hours to currentDate
*/
$currentDate += (60 * 60 * 24);
}
while(date("l", $currentDate) != "Friday");
print("</ol>\n");
?>
The code above generates the following result.