3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start_date = '2007-03-24'; $end_date = '2009-06-26'; print_r(year_month($start_date, $end_date)); //Returns an array containing the years, months and days between two dates function year_month($start_date, $end_date) { $begin = new DateTime( $start_date ); $end = new DateTime( $end_date); $end->add(new DateInterval('P1D')); //Add 1 day to include the end date as a day $interval = new DateInterval('P1W'); //Add 1 week $period = new DatePeriod($begin, $interval, $end); $aResult = array(); foreach ( $period as $dt ) { $aResult[$dt->format('Y')][$dt->format('F')][] = "Week ".$dt->format('W'); } return $aResult; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tGOqs
function name:  (null)
number of ops:  10
compiled vars:  !0 = $start_date, !1 = $end_date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '2007-03-24'
    3     1        ASSIGN                                                   !1, '2009-06-26'
    5     2        INIT_FCALL                                               'print_r'
          3        INIT_FCALL_BY_NAME                                       'year_month'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   23     9      > RETURN                                                   1

Function year_month:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 44
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 44
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/tGOqs
function name:  year_month
number of ops:  47
compiled vars:  !0 = $start_date, !1 = $end_date, !2 = $begin, !3 = $end, !4 = $interval, !5 = $period, !6 = $aResult, !7 = $dt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        NEW                                              $8      'DateTime'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $8
   12     6        NEW                                              $11     'DateTime'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !3, $11
   13    10        INIT_METHOD_CALL                                         !3, 'add'
         11        NEW                                              $14     'DateInterval'
         12        SEND_VAL_EX                                              'P1D'
         13        DO_FCALL                                      0          
         14        SEND_VAR_NO_REF_EX                                       $14
         15        DO_FCALL                                      0          
   14    16        NEW                                              $17     'DateInterval'
         17        SEND_VAL_EX                                              'P1W'
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !4, $17
   15    20        NEW                                              $20     'DatePeriod'
         21        SEND_VAR_EX                                              !2
         22        SEND_VAR_EX                                              !4
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !5, $20
   16    26        ASSIGN                                                   !6, <array>
   17    27      > FE_RESET_R                                       $24     !5, ->44
         28    > > FE_FETCH_R                                               $24, !7, ->44
   19    29    >   INIT_METHOD_CALL                                         !7, 'format'
         30        SEND_VAL_EX                                              'Y'
         31        DO_FCALL                                      0  $25     
         32        INIT_METHOD_CALL                                         !7, 'format'
         33        SEND_VAL_EX                                              'F'
         34        DO_FCALL                                      0  $27     
         35        INIT_METHOD_CALL                                         !7, 'format'
         36        SEND_VAL_EX                                              'W'
         37        DO_FCALL                                      0  $30     
         38        CONCAT                                           ~31     'Week+', $30
         39        FETCH_DIM_W                                      $26     !6, $25
         40        FETCH_DIM_W                                      $28     $26, $27
         41        ASSIGN_DIM                                               $28
         42        OP_DATA                                                  ~31
   17    43      > JMP                                                      ->28
         44    >   FE_FREE                                                  $24
   22    45      > RETURN                                                   !6
   23    46*     > RETURN                                                   null

End of function year_month

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.53 ms | 1400 KiB | 15 Q