<?php function some_func($from, $to) { $period = new DatePeriod( new DateTime($from), new DateInterval('P1D'), (new DateTime($to))->modify('+1 day') ); $dates = []; foreach ($period as $date) { $dates[] = $date->format('Y-m-d'); } return $dates; }
Standard input is empty
Array
(
[0] => 2016-09-28
[1] => 2016-09-29
[2] => 2016-09-30
[3] => 2016-10-01
[4] => 2016-10-02
[5] => 2016-10-03
[6] => 2016-10-04
[7] => 2016-10-05
[8] => 2016-10-06
[9] => 2016-10-07
[10] => 2016-10-08
[11] => 2016-10-09
[12] => 2016-10-10
[13] => 2016-10-11
[14] => 2016-10-12
[15] => 2016-10-13
[16] => 2016-10-14
[17] => 2016-10-15
[18] => 2016-10-16
[19] => 2016-10-17
[20] => 2016-10-18
[21] => 2016-10-19
[22] => 2016-10-20
[23] => 2016-10-21
[24] => 2016-10-22
[25] => 2016-10-23
[26] => 2016-10-24
[27] => 2016-10-25
[28] => 2016-10-26
[29] => 2016-10-27
[30] => 2016-10-28
[31] => 2016-10-29
[32] => 2016-10-30
[33] => 2016-10-31
[34] => 2016-11-01
[35] => 2016-11-02
[36] => 2016-11-03
[37] => 2016-11-04
[38] => 2016-11-05
[39] => 2016-11-06
[40] => 2016-11-07
[41] => 2016-11-08
[42] => 2016-11-09
[43] => 2016-11-10
[44] => 2016-11-11
[45] => 2016-11-12
[46] => 2016-11-13
[47] => 2016-11-14
[48] => 2016-11-15
[49] => 2016-11-16
[50] => 2016-11-17
[51] => 2016-11-18
[52] => 2016-11-19
[53] => 2016-11-20
[54] => 2016-11-21
[55] => 2016-11-22
[56] => 2016-11-23
)