3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = "2017-01-08"; $stop = "2017-01-20"; $chosenInterval = "week"; function getDates($start, $stop, $chosenInterval = "week") { $startDT = new DateTime($start); $stopDT = new DateTime($stop); if(isset($chosenInterval) && ($chosenInterval == "week" || $chosenInterval == "day") ) { $timeFormat = "F j, Y"; } else { $timeFormat = "F Y"; $chosenInterval = "month"; } $begin = (new DateTime($start))->modify('first day of this month'); $end = (new DateTime($stop))->modify('first day of next month'); $interval = DateInterval::createFromDateString('1 '.$chosenInterval); $period = new DatePeriod($begin, $interval, $end); foreach($period as $dt) { if ($chosenInterval !== "month" && ($dt < $startDT || $dt > $stopDT)) continue; $dataLabels[] = $dt->format($timeFormat); } return $dataLabels; } var_dump(getDates($start, $stop)); var_dump(getDates($start, $stop, "day")); var_dump(getDates($start, $stop, "month"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bZnIM
function name:  (null)
number of ops:  27
compiled vars:  !0 = $start, !1 = $stop, !2 = $chosenInterval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '2017-01-08'
    3     1        ASSIGN                                                   !1, '2017-01-20'
    4     2        ASSIGN                                                   !2, 'week'
   26     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'getdates'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                                 
   27    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'getdates'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 'day'
         15        DO_FCALL                                      0  $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                                 
   28    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'getdates'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !1
         22        SEND_VAL                                                 'month'
         23        DO_FCALL                                      0  $10     
         24        SEND_VAR                                                 $10
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Function getdates:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
2 jumps found. (Code = 47) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 49, Position 2 = 65
Branch analysis from position: 49
2 jumps found. (Code = 78) Position 1 = 50, Position 2 = 65
Branch analysis from position: 50
2 jumps found. (Code = 46) Position 1 = 52, Position 2 = 57
Branch analysis from position: 52
2 jumps found. (Code = 47) Position 1 = 54, Position 2 = 56
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 59
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 56
Branch analysis from position: 57
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 49, Position 2 = 65
Branch analysis from position: 49
Branch analysis from position: 65
Branch analysis from position: 17
Branch analysis from position: 18
filename:       /in/bZnIM
function name:  getDates
number of ops:  68
compiled vars:  !0 = $start, !1 = $stop, !2 = $chosenInterval, !3 = $startDT, !4 = $stopDT, !5 = $timeFormat, !6 = $begin, !7 = $end, !8 = $interval, !9 = $period, !10 = $dt, !11 = $dataLabels
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      'week'
    6     3        NEW                                              $12     'DateTime'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !3, $12
    7     7        NEW                                              $15     'DateTime'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !4, $15
    8    11        ISSET_ISEMPTY_CV                                 ~18     !2
         12      > JMPZ_EX                                          ~18     ~18, ->18
         13    >   IS_EQUAL                                         ~19     !2, 'week'
         14      > JMPNZ_EX                                         ~19     ~19, ->17
         15    >   IS_EQUAL                                         ~20     !2, 'day'
         16        BOOL                                             ~19     ~20
         17    >   BOOL                                             ~18     ~19
         18    > > JMPZ                                                     ~18, ->21
    9    19    >   ASSIGN                                                   !5, 'F+j%2C+Y'
    8    20      > JMP                                                      ->23
   11    21    >   ASSIGN                                                   !5, 'F+Y'
   12    22        ASSIGN                                                   !2, 'month'
   15    23    >   NEW                                              $24     'DateTime'
         24        SEND_VAR_EX                                              !0
         25        DO_FCALL                                      0          
         26        INIT_METHOD_CALL                                         $24, 'modify'
         27        SEND_VAL_EX                                              'first+day+of+this+month'
         28        DO_FCALL                                      0  $26     
         29        ASSIGN                                                   !6, $26
   16    30        NEW                                              $28     'DateTime'
         31        SEND_VAR_EX                                              !1
         32        DO_FCALL                                      0          
         33        INIT_METHOD_CALL                                         $28, 'modify'
         34        SEND_VAL_EX                                              'first+day+of+next+month'
         35        DO_FCALL                                      0  $30     
         36        ASSIGN                                                   !7, $30
   17    37        INIT_STATIC_METHOD_CALL                                  'DateInterval', 'createFromDateString'
         38        CONCAT                                           ~32     '1+', !2
         39        SEND_VAL                                                 ~32
         40        DO_FCALL                                      0  $33     
         41        ASSIGN                                                   !8, $33
   18    42        NEW                                              $35     'DatePeriod'
         43        SEND_VAR_EX                                              !6
         44        SEND_VAR_EX                                              !8
         45        SEND_VAR_EX                                              !7
         46        DO_FCALL                                      0          
         47        ASSIGN                                                   !9, $35
   20    48      > FE_RESET_R                                       $38     !9, ->65
         49    > > FE_FETCH_R                                               $38, !10, ->65
   21    50    >   IS_NOT_IDENTICAL                                 ~39     !2, 'month'
         51      > JMPZ_EX                                          ~39     ~39, ->57
         52    >   IS_SMALLER                                       ~40     !10, !3
         53      > JMPNZ_EX                                         ~40     ~40, ->56
         54    >   IS_SMALLER                                       ~41     !4, !10
         55        BOOL                                             ~40     ~41
         56    >   BOOL                                             ~39     ~40
         57    > > JMPZ                                                     ~39, ->59
         58    > > JMP                                                      ->49
   22    59    >   INIT_METHOD_CALL                                         !10, 'format'
         60        SEND_VAR_EX                                              !5
         61        DO_FCALL                                      0  $43     
         62        ASSIGN_DIM                                               !11
         63        OP_DATA                                                  $43
   20    64      > JMP                                                      ->49
         65    >   FE_FREE                                                  $38
   24    66      > RETURN                                                   !11
   25    67*     > RETURN                                                   null

End of function getdates

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.03 ms | 1016 KiB | 17 Q