Finding every date between two dates

Hello,

Does anyone know how to find every date between two dates in an array, and add them to the array?

Thanks,

Jon

Thanks for that, it works perfectly.

Cheers,

Jon

If this is coming from an SQL query you can do:

SELECT * FROM some_place 
WHERE your_field 
BETWEEN '2000-10-10' AND '2010-10-10'

$dates = array(
  "2010-07-26", // start date
  "2010-08-25", // end date
);

// remove end date from array (we'll add it back later)
// and store it in a variable
$endDate = strtotime(array_pop($dates));

// store start date in a variable, we'll use it to increment
// date by 1 day to find all dates up to end date
$current = strtotime($dates[0]);

// increment current by one day and add it to our array
// until we reach end date
while(($current = strtotime("+1 day", $current)) <= $endDate) {
  $dates[] = date("Y-m-d", $current);
}

var_dump($dates);