3v4l.org

run code in 500+ 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 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 25
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 25
Branch analysis from position: 42
Branch analysis from position: 25
Branch analysis from position: 37
Branch analysis from position: 23
Branch analysis from position: 15
filename:       /in/ov9tk
function name:  getPossibleShippingDates
number of ops:  44
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_METHOD_CALL                                             !3, 'format'
         16        SEND_VAL_EX                                                  'N'
         17        DO_FCALL                                          0  $12     
         18        FRAMELESS_ICALL_2                in_array            ~13     $12, <array>
         19      > JMPZ                                                         ~13, ->23
   12    20    >   INIT_METHOD_CALL                                             !3, 'modify'
         21        SEND_VAL_EX                                                  'next+monday'
         22        DO_FCALL                                          0          
   15    23    >   ASSIGN                                                       !4, 1
   16    24      > JMP                                                          ->40
   17    25    >   INIT_METHOD_CALL                                             !3, 'format'
         26        SEND_VAL_EX                                                  'N'
         27        DO_FCALL                                          0  $16     
         28        FRAMELESS_ICALL_2                in_array            ~17     $16, <array>
         29        BOOL_NOT                                             ~18     ~17
         30      > JMPZ                                                         ~18, ->37
   18    31    >   POST_INC                                             ~19     !4
         32        INIT_METHOD_CALL                                             !3, 'format'
         33        SEND_VAL_EX                                                  'Y-m-d'
         34        DO_FCALL                                          0  $21     
         35        ASSIGN_DIM                                                   !2, ~19
         36        OP_DATA                                                      $21
   20    37    >   INIT_METHOD_CALL                                             !3, 'modify'
         38        SEND_VAL_EX                                                  '%2B1+day'
         39        DO_FCALL                                          0          
   16    40    >   IS_SMALLER_OR_EQUAL                                          !4, !1
         41      > JMPNZ                                                        ~23, ->25
   23    42    > > RETURN                                                       !2
   24    43*     > RETURN                                                       null

End of function getpossibleshippingdates

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
192.98 ms | 2200 KiB | 15 Q