3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add_deadline($givenDate, $hours){ $range = (ceil($hours/7)*120); $cnt=1; $goodhours = array(); foreach(range(1,$range) as $num): $datetime = date("Y-m-d H:i:s", strtotime('+'.$num.' hour',strtotime($givenDate))); $time = date("Hi", strtotime('+'.$num.' hour',strtotime($givenDate))); $day = date("D", strtotime('+'.$num.' hour', strtotime($givenDate))); if($day != 'Sat' && $day != 'Sun' && $time >= 830 && $time <= 1730): $goodhours[$cnt] = $datetime; if($cnt >= $hours && array_key_exists($hours,$goodhours)): return $goodhours[$hours]; break; endif; $cnt++; endif; endforeach; } //Pass in date and the hours to add on $future = add_deadline('2014-06-27 08:30:00', '65'); echo $future;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tAdX2
function name:  (null)
number of ops:  7
compiled vars:  !0 = $future
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'add_deadline'
          1        SEND_VAL                                                 '2014-06-27+08%3A30%3A00'
          2        SEND_VAL                                                 '65'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   28     5        ECHO                                                     !0
          6      > RETURN                                                   1

Function add_deadline:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 82
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 82
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 60, Position 2 = 62
Branch analysis from position: 60
2 jumps found. (Code = 46) Position 1 = 63, Position 2 = 65
Branch analysis from position: 63
2 jumps found. (Code = 46) Position 1 = 66, Position 2 = 68
Branch analysis from position: 66
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 81
Branch analysis from position: 69
2 jumps found. (Code = 46) Position 1 = 73, Position 2 = 75
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 80
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 75
Branch analysis from position: 81
Branch analysis from position: 68
Branch analysis from position: 65
Branch analysis from position: 62
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 82
filename:       /in/tAdX2
function name:  add_deadline
number of ops:  84
compiled vars:  !0 = $givenDate, !1 = $hours, !2 = $range, !3 = $cnt, !4 = $goodhours, !5 = $num, !6 = $datetime, !7 = $time, !8 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'ceil'
          3        DIV                                              ~9      !1, 7
          4        SEND_VAL                                                 ~9
          5        DO_ICALL                                         $10     
          6        MUL                                              ~11     $10, 120
          7        ASSIGN                                                   !2, ~11
    4     8        ASSIGN                                                   !3, 1
    5     9        ASSIGN                                                   !4, <array>
    6    10        INIT_FCALL                                               'range'
         11        SEND_VAL                                                 1
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $15     
         14      > FE_RESET_R                                       $16     $15, ->82
         15    > > FE_FETCH_R                                               $16, !5, ->82
    8    16    >   INIT_FCALL                                               'date'
         17        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         18        INIT_FCALL                                               'strtotime'
         19        CONCAT                                           ~17     '%2B', !5
         20        CONCAT                                           ~18     ~17, '+hour'
         21        SEND_VAL                                                 ~18
         22        INIT_FCALL                                               'strtotime'
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $19     
         25        SEND_VAR                                                 $19
         26        DO_ICALL                                         $20     
         27        SEND_VAR                                                 $20
         28        DO_ICALL                                         $21     
         29        ASSIGN                                                   !6, $21
    9    30        INIT_FCALL                                               'date'
         31        SEND_VAL                                                 'Hi'
         32        INIT_FCALL                                               'strtotime'
         33        CONCAT                                           ~23     '%2B', !5
         34        CONCAT                                           ~24     ~23, '+hour'
         35        SEND_VAL                                                 ~24
         36        INIT_FCALL                                               'strtotime'
         37        SEND_VAR                                                 !0
         38        DO_ICALL                                         $25     
         39        SEND_VAR                                                 $25
         40        DO_ICALL                                         $26     
         41        SEND_VAR                                                 $26
         42        DO_ICALL                                         $27     
         43        ASSIGN                                                   !7, $27
   10    44        INIT_FCALL                                               'date'
         45        SEND_VAL                                                 'D'
         46        INIT_FCALL                                               'strtotime'
         47        CONCAT                                           ~29     '%2B', !5
         48        CONCAT                                           ~30     ~29, '+hour'
         49        SEND_VAL                                                 ~30
         50        INIT_FCALL                                               'strtotime'
         51        SEND_VAR                                                 !0
         52        DO_ICALL                                         $31     
         53        SEND_VAR                                                 $31
         54        DO_ICALL                                         $32     
         55        SEND_VAR                                                 $32
         56        DO_ICALL                                         $33     
         57        ASSIGN                                                   !8, $33
   12    58        IS_NOT_EQUAL                                     ~35     !8, 'Sat'
         59      > JMPZ_EX                                          ~35     ~35, ->62
         60    >   IS_NOT_EQUAL                                     ~36     !8, 'Sun'
         61        BOOL                                             ~35     ~36
         62    > > JMPZ_EX                                          ~35     ~35, ->65
         63    >   IS_SMALLER_OR_EQUAL                              ~37     830, !7
         64        BOOL                                             ~35     ~37
         65    > > JMPZ_EX                                          ~35     ~35, ->68
         66    >   IS_SMALLER_OR_EQUAL                              ~38     !7, 1730
         67        BOOL                                             ~35     ~38
         68    > > JMPZ                                                     ~35, ->81
   13    69    >   ASSIGN_DIM                                               !4, !3
         70        OP_DATA                                                  !6
   15    71        IS_SMALLER_OR_EQUAL                              ~40     !1, !3
         72      > JMPZ_EX                                          ~40     ~40, ->75
         73    >   ARRAY_KEY_EXISTS                                 ~41     !1, !4
         74        BOOL                                             ~40     ~41
         75    > > JMPZ                                                     ~40, ->80
   16    76    >   FETCH_DIM_R                                      ~42     !4, !1
         77        FE_FREE                                                  $16
         78      > RETURN                                                   ~42
   17    79*       JMP                                                      ->82
   20    80    >   PRE_INC                                                  !3
    6    81    > > JMP                                                      ->15
         82    >   FE_FREE                                                  $16
   24    83      > RETURN                                                   null

End of function add_deadline

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.61 ms | 1407 KiB | 22 Q