Use for statement to print day name in PHP

Description

The following code shows how to use for statement to print day name.

Example


<?php/*from  w  w w  .j  ava2  s . c o m*/
  /*
  ** print some text explaining the output
  */
  print("Days left before Friday:\n");
  print("<ol>\n");
  for($currentDate = date("U"); 
    date("l", $currentDate) != "Friday"; 
    $currentDate += (60 * 60 * 24))
  {
    /*
    ** print day name
    */
    print("<li>" . date("l", $currentDate) . "</li>\n");
  }
  print("</ol>\n");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone