3v4l.org

run code in 500+ 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 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 12
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 12
Branch analysis from position: 35
Branch analysis from position: 12
filename:       /in/ouK2q
function name:  rangeWeek
number of ops:  39
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                                                          ->33
    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_METHOD_CALL                                             !2, 'modify'
         17        SEND_VAL_EX                                                  'Sunday+this+week'
         18        DO_FCALL                                          0  $13     
         19        FRAMELESS_ICALL_2                min                 ~14     !3, $13
         20        INIT_METHOD_CALL                                             ~14, 'format'
         21        SEND_VAL_EX                                                  'Y-m-d'
         22        DO_FCALL                                          0  $15     
         23        ADD_ARRAY_ELEMENT                                    ~12     $15, 'end'
   11    24        INIT_METHOD_CALL                                             !2, 'format'
         25        SEND_VAL_EX                                                  'W'
         26        DO_FCALL                                          0  $16     
         27        ADD_ARRAY_ELEMENT                                    ~12     $16, 'week'
    8    28        ASSIGN_DIM                                                   !4
   11    29        OP_DATA                                                      ~12
   13    30        INIT_METHOD_CALL                                             !2, 'modify'
         31        SEND_VAL_EX                                                  'next+Monday'
         32        DO_FCALL                                          0          
    7    33    >   IS_SMALLER_OR_EQUAL                                          !2, !3
         34      > JMPNZ                                                        ~18, ->12
   15    35    >   VERIFY_RETURN_TYPE                                           !4
         36      > RETURN                                                       !4
   16    37*       VERIFY_RETURN_TYPE                                           
         38*     > RETURN                                                       null

End of function rangeweek

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.14 ms | 1947 KiB | 18 Q