PHP Classes

File: call.php

Recommend this page to a friend!
  Classes of Paul  >  List Days  >  call.php  >  Download  
File: call.php
Role: Example script
Content type: text/plain
Description: Sample class call and sample array parsing function
Class: List Days
Retrieve the list of all days between two dates
Author: By
Last change:
Date: 8 years ago
Size: 1,532 bytes


Class file image Download

// Require our class //

$days_call = new listDays;
// Make an array with years, months and days from 1st January 2008 till today (using date() function); //
// Remember to use four-digit years and months and days without leading zero //
// This is just an example, you can also list days in past or future, but remember that the "FROM" date has to be before the "TO" date //

// Call the makeArray function like: makeArray(FROM_YEAR,FROM_MONTH,FROM_DAY,TO_YEAR,TO_MONTH,TO_DAY) //
$days = $days_call -> makeArray(2008,1,1,date("Y"),date("n"),date("j"));

// Print_readable our $days array //

// Simple foreach() use on our array //
// All days counter, starting from zero because our days array also starts from zero //
$day_counter = 0;
$days as $day) {
// Explode each array element using "|" to have element[0] as year, element[1] as month and element[2] as day. //
$days_actual = explode("|", $days["day_".$day_counter]);
// To display a correct day number always add 1 to day counter (but only for display purposes, because as i wrote before array starts from 0, //
    // so if you start day_counter from 1, your first array element will be the second day after giver "FROM" date and the last //
    // array element will be empty. //
print("Day ".($day_counter+1).": year = ".$days_actual[0].", month = ".$days_actual[1].", day = ".$days_actual[2]."<br>\n");
// Raise day counter by 1 //