3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTime('2012-01-01'); $start->modify('first day of this month'); $end = new DateTime(); $end->modify('last day of next month'); $interval = DateInterval::createFromDateString('4 month'); $period = new DatePeriod($start, $interval, $end); foreach ($period as $dt) { // echo $dt->format("Y-m-d") . PHP_EOL; $date[$dt->format("Y")][] = $dt->format("Y-m-d"); } print_r($date);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 35
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 35
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/TYUPv
function name:  (null)
number of ops:  40
compiled vars:  !0 = $start, !1 = $end, !2 = $interval, !3 = $period, !4 = $dt, !5 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $6      'DateTime'
          1        SEND_VAL_EX                                              '2012-01-01'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $6
    3     4        INIT_METHOD_CALL                                         !0, 'modify'
          5        SEND_VAL_EX                                              'first+day+of+this+month'
          6        DO_FCALL                                      0          
    4     7        NEW                                              $10     'DateTime'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $10
    5    10        INIT_METHOD_CALL                                         !1, 'modify'
         11        SEND_VAL_EX                                              'last+day+of+next+month'
         12        DO_FCALL                                      0          
    6    13        INIT_STATIC_METHOD_CALL                                  'DateInterval', 'createFromDateString'
         14        SEND_VAL                                                 '4+month'
         15        DO_FCALL                                      0  $14     
         16        ASSIGN                                                   !2, $14
    7    17        NEW                                              $16     'DatePeriod'
         18        SEND_VAR_EX                                              !0
         19        SEND_VAR_EX                                              !2
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !3, $16
    9    23      > FE_RESET_R                                       $19     !3, ->35
         24    > > FE_FETCH_R                                               $19, !4, ->35
   11    25    >   INIT_METHOD_CALL                                         !4, 'format'
         26        SEND_VAL_EX                                              'Y'
         27        DO_FCALL                                      0  $20     
         28        INIT_METHOD_CALL                                         !4, 'format'
         29        SEND_VAL_EX                                              'Y-m-d'
         30        DO_FCALL                                      0  $23     
         31        FETCH_DIM_W                                      $21     !5, $20
         32        ASSIGN_DIM                                               $21
         33        OP_DATA                                                  $23
    9    34      > JMP                                                      ->24
         35    >   FE_FREE                                                  $19
   14    36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !5
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.21 ms | 1400 KiB | 15 Q