3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'Saturday-Thursday'; list($begin, $end) = array_map(fn($d) => new DateTime($d), explode('-', $str)); $end = $end->modify($end < $begin ? '+8 days':'+1 day'); $interval = new DateInterval('P1D'); $daterange = new DatePeriod($begin, $interval, $end); $result = array_map(fn($d) => $d->format('l'), [...$daterange]); print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NvPgC
function name:  (null)
number of ops:  46
compiled vars:  !0 = $str, !1 = $begin, !2 = $end, !3 = $interval, !4 = $daterange, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Saturday-Thursday'
    4     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          3        SEND_VAL                                                 ~7
          4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '-'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $8      
          8        SEND_VAR                                                 $8
          9        DO_ICALL                                         $9      
         10        FETCH_LIST_R                                     $10     $9, 0
         11        ASSIGN                                                   !1, $10
         12        FETCH_LIST_R                                     $12     $9, 1
         13        ASSIGN                                                   !2, $12
         14        FREE                                                     $9
    6    15        INIT_METHOD_CALL                                         !2, 'modify'
         16        IS_SMALLER                                               !2, !1
         17      > JMPZ                                                     ~14, ->20
         18    >   QM_ASSIGN                                        ~15     '%2B8+days'
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~15     '%2B1+day'
         21    >   SEND_VAL_EX                                              ~15
         22        DO_FCALL                                      0  $16     
         23        ASSIGN                                                   !2, $16
    8    24        NEW                                              $18     'DateInterval'
         25        SEND_VAL_EX                                              'P1D'
         26        DO_FCALL                                      0          
         27        ASSIGN                                                   !3, $18
    9    28        NEW                                              $21     'DatePeriod'
         29        SEND_VAR_EX                                              !1
         30        SEND_VAR_EX                                              !3
         31        SEND_VAR_EX                                              !2
         32        DO_FCALL                                      0          
         33        ASSIGN                                                   !4, $21
   11    34        INIT_FCALL                                               'array_map'
         35        DECLARE_LAMBDA_FUNCTION                          ~24     [1]
         36        SEND_VAL                                                 ~24
         37        INIT_ARRAY                                       ~25     
         38        ADD_ARRAY_UNPACK                                 ~25     !4
         39        SEND_VAL                                                 ~25
         40        DO_ICALL                                         $26     
         41        ASSIGN                                                   !5, $26
   13    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !5
         44        DO_ICALL                                                 
         45      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NvPgC
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        NEW                                              $1      'DateTime'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NvPgC
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        INIT_METHOD_CALL                                         !0, 'format'
          2        SEND_VAL_EX                                              'l'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.47 ms | 1007 KiB | 16 Q