note 100988 deleted from function.strtotime by danbrown

From: Date: Fri, 19 Nov 2010 14:25:26 +0000
Subject: note 100988 deleted from function.strtotime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174197@lists.php.net to get a copy of this message
Note Submitter: elitezenithweb AT gmail DOT com ---- I mean... <?php function wdates($start = 0, $amount = 10, $format = 'Y', $interval = 'Y', $decrease = true) { // Determining where we should start the dates (In years) $start = ((is_numeric($start)) ? $start : 0); // Accomidating the AMOUNT returned accordignly to the START $amount += $start; // Creating an array of years {$amount} times for($i = $start; $i < $amount; ++$i) { // Checking the interval to increase/decrease by $int = (($interval == 'D') ? 'day' : (($interval == 'M') ? 'month' : 'year')); // Checking if we are decreasing or increasing $loop = (($decrease == true) ? '-' : '+'); // Creating the appropriate time stampe $tmsp = strtotime($loop . $i . ' ' . $int); // Building the date array $date_arr[] = date($format, $tmsp); } // Returning the date array return $date_arr; } print_r(wdates(12,7)); ?> Which prints Array ( [0] => 1998 [1] => 1997 [2] => 1996 [3] => 1995 [4] => 1994 [5] => 1993 [6] => 1992 ) ... 7 results rather then 1 more then needed...

« previous php.notes (#174197) next »