3v4l.org

run code in 300+ PHP versions simultaneously
<?php $order_date = '2020-07-09 10:23:00'; // if no argument the, use the current time function getPossibleShippingDates($order_date = 'now', $num_day = 3) { $dates = []; $dt = new DateTime($order_date); if ($dt->format('H') >= 10) { // if ordered on or after 10, move to next day $dt->modify('+1 day'); } if (in_array($dt->format('N'), [6, 7])) { // if ordered weekend, adjust to start monday $dt->modify('next monday'); } $i = 1; while ($i <= $num_day) { if (!in_array($dt->format('N'), [6, 7])) { $dates[$i++] = $dt->format('Y-m-d'); } $dt->modify('+1 day'); } return $dates; } $dates = getPossibleShippingDates($order_date); print_r($dates);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ov9tk
function name:  (null)
number of ops:  9
compiled vars:  !0 = $order_date, !1 = $dates
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2020-07-09+10%3A23%3A00'
   26     1        INIT_FCALL                                               'getpossibleshippingdates'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   27     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function getpossibleshippingdates:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 28
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 28
Branch analysis from position: 48
Branch analysis from position: 28
Branch analysis from position: 43
Branch analysis from position: 26
Branch analysis from position: 15
filename:       /in/ov9tk
function name:  getPossibleShippingDates
number of ops:  50
compiled vars:  !0 = $order_date, !1 = $num_day, !2 = $dates, !3 = $dt, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_INIT                                        !0      'now'
          1        RECV_INIT                                        !1      3
    5     2        ASSIGN                                                   !2, <array>
    6     3        NEW                                              $6      'DateTime'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !3, $6
    8     7        INIT_METHOD_CALL                                         !3, 'format'
          8        SEND_VAL_EX                                              'H'
          9        DO_FCALL                                      0  $9      
         10        IS_SMALLER_OR_EQUAL                                      10, $9
         11      > JMPZ                                                     ~10, ->15
    9    12    >   INIT_METHOD_CALL                                         !3, 'modify'
         13        SEND_VAL_EX                                              '%2B1+day'
         14        DO_FCALL                                      0          
   11    15    >   INIT_FCALL                                               'in_array'
         16        INIT_METHOD_CALL                                         !3, 'format'
         17        SEND_VAL_EX                                              'N'
         18        DO_FCALL                                      0  $12     
         19        SEND_VAR                                                 $12
         20        SEND_VAL                                                 <array>
         21        DO_ICALL                                         $13     
         22      > JMPZ                                                     $13, ->26
   12    23    >   INIT_METHOD_CALL                                         !3, 'modify'
         24        SEND_VAL_EX                                              'next+monday'
         25        DO_FCALL                                      0          
   15    26    >   ASSIGN                                                   !4, 1
   16    27      > JMP                                                      ->46
   17    28    >   INIT_FCALL                                               'in_array'
         29        INIT_METHOD_CALL                                         !3, 'format'
         30        SEND_VAL_EX                                              'N'
         31        DO_FCALL                                      0  $16     
         32        SEND_VAR                                                 $16
         33        SEND_VAL                                                 <array>
         34        DO_ICALL                                         $17     
         35        BOOL_NOT                                         ~18     $17
         36      > JMPZ                                                     ~18, ->43
   18    37    >   POST_INC                                         ~19     !4
         38        INIT_METHOD_CALL                                         !3, 'format'
         39        SEND_VAL_EX                                              'Y-m-d'
         40        DO_FCALL                                      0  $21     
         41        ASSIGN_DIM                                               !2, ~19
         42        OP_DATA                                                  $21
   20    43    >   INIT_METHOD_CALL                                         !3, 'modify'
         44        SEND_VAL_EX                                              '%2B1+day'
         45        DO_FCALL                                      0          
   16    46    >   IS_SMALLER_OR_EQUAL                                      !4, !1
         47      > JMPNZ                                                    ~23, ->28
   23    48    > > RETURN                                                   !2
   24    49*     > RETURN                                                   null

End of function getpossibleshippingdates

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.73 ms | 1019 KiB | 16 Q