Ok, I hate dates :p but here's a try at it. Just returns a simple 1D array using split()
<?php
/* FUNCTION TAKES THE STARTING DATE AND END DATE AS STRING
AND FINDS ALL THE DATES BETWEEN THEM, SPLITS AND RETURNS SIMPLE ARRAY */
function listdates($startdate,$enddate){
$startdate = strtotime($startdate);
$enddate = strtotime($enddate);
$i = $startdate;
while($i <= $enddate) {
$dates = $dates."-".date("F d, Y",$i);
$i = $i + 86400;
}
$ardates = split("-",$dates);
return $ardates;
}
/**************************************/
/* DATES FROM FORM, URL, ETC */
$startdate = "January 15, 2003";
$enddate = "February 10, 2003";
$mydates = listdates($startdate,$enddate);
echo count($mydates)." days between ".$startdate." and ".$enddate."...<br>";
/* LOOP THRU AND LIST THE DATES JUST TO SEE */
for($i = 0; $i <= count($mydates);$i++){
echo $mydates[$i]."<br>";
}
?>
I'll work on a more elegant approach this, I think. Hope this helps though!
EDIT: Blah, a bug. Starting the loop like I did leaves ardates[0] empty. All the dates are there, but they start at [1]. Hmmm. Suggestions are welcome! 🙂