3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rangeWeek(string $start,string $end): array{ $dtStart = date_create($start); $dtEnd = date_create($end); $weeks = []; while($dtStart <= $dtEnd){ $weeks[] = [ 'start' => $dtStart->format('Y-m-d'), 'end' => min($dtEnd,$dtStart->modify('Sunday this week'))->format('Y-m-d'), 'week' => $dtStart->format('W') ]; $dtStart->modify('next Monday'); } return $weeks; } $startDate = '2022-08-08'; //Monday $endDate = '2022-08-23'; //Tuesday $weeks = rangeWeek($startDate, $endDate); var_dump($weeks);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ouK2q
function name:  (null)
number of ops:  11
compiled vars:  !0 = $startDate, !1 = $endDate, !2 = $weeks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, '2022-08-08'
   19     1        ASSIGN                                                   !1, '2022-08-23'
   20     2        INIT_FCALL                                               'rangeweek'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   21     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function rangeweek:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 12
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 12
Branch analysis from position: 38
Branch analysis from position: 12
filename:       /in/ouK2q
function name:  rangeWeek
number of ops:  42
compiled vars:  !0 = $start, !1 = $end, !2 = $dtStart, !3 = $dtEnd, !4 = $weeks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'date_create'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
    5     6        INIT_FCALL                                               'date_create'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !3, $7
    6    10        ASSIGN                                                   !4, <array>
    7    11      > JMP                                                      ->36
    9    12    >   INIT_METHOD_CALL                                         !2, 'format'
         13        SEND_VAL_EX                                              'Y-m-d'
         14        DO_FCALL                                      0  $11     
         15        INIT_ARRAY                                       ~12     $11, 'start'
   10    16        INIT_FCALL                                               'min'
         17        SEND_VAR                                                 !3
         18        INIT_METHOD_CALL                                         !2, 'modify'
         19        SEND_VAL_EX                                              'Sunday+this+week'
         20        DO_FCALL                                      0  $13     
         21        SEND_VAR                                                 $13
         22        DO_ICALL                                         $14     
         23        INIT_METHOD_CALL                                         $14, 'format'
         24        SEND_VAL_EX                                              'Y-m-d'
         25        DO_FCALL                                      0  $15     
         26        ADD_ARRAY_ELEMENT                                ~12     $15, 'end'
   11    27        INIT_METHOD_CALL                                         !2, 'format'
         28        SEND_VAL_EX                                              'W'
         29        DO_FCALL                                      0  $16     
         30        ADD_ARRAY_ELEMENT                                ~12     $16, 'week'
    8    31        ASSIGN_DIM                                               !4
   11    32        OP_DATA                                                  ~12
   13    33        INIT_METHOD_CALL                                         !2, 'modify'
         34        SEND_VAL_EX                                              'next+Monday'
         35        DO_FCALL                                      0          
    7    36    >   IS_SMALLER_OR_EQUAL                                      !2, !3
         37      > JMPNZ                                                    ~18, ->12
   15    38    >   VERIFY_RETURN_TYPE                                       !4
         39      > RETURN                                                   !4
   16    40*       VERIFY_RETURN_TYPE                                       
         41*     > RETURN                                                   null

End of function rangeweek

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.52 ms | 1014 KiB | 17 Q