Have a look at DatePeriod
. You can create a DatePeriod and map over it to create an array of dates, like so:
// create DatePeriod with the following arguments:
//
// * DateTime for current datetime
// * DateInterval of 1 day
// * Recurrences - today's date *plus* this number of repeated dates
$period = new DatePeriod(new DateTime(), new DateInterval('P1D'), 9);
// Convert DatePeriod to array of DateTime objects
// Map over array
// Build array of formatted date strings
$dates = array_map(function($dt) {
return $dt->format('d/m/Y');
}, iterator_to_array($period));
// Done :)
var_dump($dates);
This yields something like:
array (size=11)
0 => string '12/03/2015' (length=10)
1 => string '13/03/2015' (length=10)
2 => string '14/03/2015' (length=10)
3 => string '15/03/2015' (length=10)
4 => string '16/03/2015' (length=10)
5 => string '17/03/2015' (length=10)
6 => string '18/03/2015' (length=10)
7 => string '19/03/2015' (length=10)
8 => string '20/03/2015' (length=10)
9 => string '21/03/2015' (length=10)
Note that recurrences is one less as it does not include the start date.
Hope this helps :)