fork download
  1. <?php
  2.  
  3. function some_func($from, $to) {
  4. $period = new DatePeriod(
  5. new DateTime($from),
  6. new DateInterval('P1D'),
  7. (new DateTime($to))->modify('+1 day')
  8. );
  9.  
  10. $dates = [];
  11. foreach ($period as $date) {
  12. $dates[] = $date->format('Y-m-d');
  13. }
  14. return $dates;
  15. }
  16.  
  17. print_r(some_func('2016-09-28', '2016-11-23'));
  18.  
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
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
)