3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getIntervals($start_date, $end_date, $period) { $period_formats = array( 'day' => 'Y-m-d', 'week' => 'Y-W', 'month' => 'Y-m', 'year' => 'Y' ); $start = new DateTime($start_date); if($period != 'day') { $start->modify('first day of this '.$period); } $end = new DateTime($end_date); if($period != 'day') { $end->modify('first day of next '.$period); } $interval = DateInterval::createFromDateString('1 '.$period); $period = new DatePeriod($start, $interval, $end); foreach ($period as $dt) { echo $dt->format($period_formats[$period]) . "<br>\n"; } } getIntervals('2014-06-01', '2014-10-18', 'day'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uUAFP
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'getintervals'
          1        SEND_VAL                                                 '2014-06-01'
          2        SEND_VAL                                                 '2014-10-18'
          3        SEND_VAL                                                 'day'
          4        DO_FCALL                                      0          
   26     5      > RETURN                                                   1

Function getintervals:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 36, Position 2 = 45
Branch analysis from position: 36
2 jumps found. (Code = 78) Position 1 = 37, Position 2 = 45
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
Branch analysis from position: 24
Branch analysis from position: 14
filename:       /in/uUAFP
function name:  getIntervals
number of ops:  47
compiled vars:  !0 = $start_date, !1 = $end_date, !2 = $period, !3 = $period_formats, !4 = $start, !5 = $end, !6 = $interval, !7 = $dt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    3     3        ASSIGN                                                   !3, <array>
    9     4        NEW                                              $9      'DateTime'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !4, $9
   10     8        IS_NOT_EQUAL                                             !2, 'day'
          9      > JMPZ                                                     ~12, ->14
   11    10    >   INIT_METHOD_CALL                                         !4, 'modify'
         11        CONCAT                                           ~13     'first+day+of+this+', !2
         12        SEND_VAL_EX                                              ~13
         13        DO_FCALL                                      0          
   13    14    >   NEW                                              $15     'DateTime'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !5, $15
   14    18        IS_NOT_EQUAL                                             !2, 'day'
         19      > JMPZ                                                     ~18, ->24
   15    20    >   INIT_METHOD_CALL                                         !5, 'modify'
         21        CONCAT                                           ~19     'first+day+of+next+', !2
         22        SEND_VAL_EX                                              ~19
         23        DO_FCALL                                      0          
   17    24    >   INIT_STATIC_METHOD_CALL                                  'DateInterval', 'createFromDateString'
         25        CONCAT                                           ~21     '1+', !2
         26        SEND_VAL                                                 ~21
         27        DO_FCALL                                      0  $22     
         28        ASSIGN                                                   !6, $22
   18    29        NEW                                              $24     'DatePeriod'
         30        SEND_VAR_EX                                              !4
         31        SEND_VAR_EX                                              !6
         32        SEND_VAR_EX                                              !5
         33        DO_FCALL                                      0          
         34        ASSIGN                                                   !2, $24
   20    35      > FE_RESET_R                                       $27     !2, ->45
         36    > > FE_FETCH_R                                               $27, !7, ->45
   21    37    >   INIT_METHOD_CALL                                         !7, 'format'
         38        CHECK_FUNC_ARG                                           
         39        FETCH_DIM_FUNC_ARG                               $28     !3, !2
         40        SEND_FUNC_ARG                                            $28
         41        DO_FCALL                                      0  $29     
         42        CONCAT                                           ~30     $29, '%3Cbr%3E%0A'
         43        ECHO                                                     ~30
   20    44      > JMP                                                      ->36
         45    >   FE_FREE                                                  $27
   23    46      > RETURN                                                   null

End of function getintervals

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.74 ms | 1394 KiB | 14 Q