Use while to print day namee in PHP

Description

The following code shows how to use while to print day namee.

Example


<?php/*from w  w  w .  j  a  v a2s  .  co m*/
  //get the current date in number of seconds
  $currentDate = time();

  //print some text explaining the output
  print("Days left before Friday:\n");
  print("<ol>\n");
  while(date("l", $currentDate) != "Friday")
  {
    //print day name
    print("<li>" . date("l", $currentDate) . "</li>\n");

    //add 24 hours to currentDate
    $currentDate += (60 * 60 * 24);
  }
  print("</ol>\n");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition