3v4l.org

run code in 300+ PHP versions simultaneously
<?php $starttime = '5'; $endtime = '17'; $timings = array( '0' => '12AM', '1' => '1AM', '2' => '2AM', '3' => '3AM', '4' => '4AM', '5' => '5AM', '6' => '6AM', '7' => '7AM', '8' => '8AM', '9' => '9AM', '10' => '10AM', '11' => '11AM', '12' => '12PM', '13' => '1PM', '14' => '2PM', '15' => '3PM', '16' => '4PM', '17' => '5PM', '18' => '6PM', '19' => '7PM', '20' => '8PM', '21' => '9PM', '22' => '10PM', '23' => '11PM', ); function diffKeys($timings, $starttime, $endtime) { return array_diff_key($timings, array_flip(range($starttime, $endtime))); } function spliceKeys($timings, $starttime, $endtime) { array_splice($timings, $starttime, $endtime - $starttime); return $timings; } function sliceKeys($timings, $starttime, $endtime) { return array_merge( array_slice($timings, 0, $starttime), array_slice($timings, $endtime + 1) ); } function skipKeys($timings, $starttime, $endtime) { $result = []; foreach ($timings as $military => $timing) { if ($military >= $starttime && $military <= $endtime) { continue; } $result[$military] = $timing; } return $result; } function unsetKeys($timings, $starttime, $endtime) { $result = []; foreach ($timings as $military => $timing) { if ($military >= $starttime && $military <= $endtime) { unset($timings[$military]); } } return $timings; } var_export(diffKeys($timings, $starttime, $endtime)); echo "\n---\n"; var_export(spliceKeys($timings, $starttime, $endtime)); echo "\n---\n"; var_export(sliceKeys($timings, $starttime, $endtime)); echo "\n---\n"; var_export(skipKeys($timings, $starttime, $endtime)); echo "\n---\n"; var_export(unsetKeys($timings, $starttime, $endtime));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Mss8J
function name:  (null)
number of ops:  48
compiled vars:  !0 = $starttime, !1 = $endtime, !2 = $timings
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '5'
    4     1        ASSIGN                                                   !1, '17'
    5     2        ASSIGN                                                   !2, <array>
   70     3        INIT_FCALL                                               'var_export'
          4        INIT_FCALL                                               'diffkeys'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   71    11        ECHO                                                     '%0A---%0A'
   72    12        INIT_FCALL                                               'var_export'
         13        INIT_FCALL                                               'splicekeys'
         14        SEND_VAR                                                 !2
         15        SEND_VAR                                                 !0
         16        SEND_VAR                                                 !1
         17        DO_FCALL                                      0  $8      
         18        SEND_VAR                                                 $8
         19        DO_ICALL                                                 
   73    20        ECHO                                                     '%0A---%0A'
   74    21        INIT_FCALL                                               'var_export'
         22        INIT_FCALL                                               'slicekeys'
         23        SEND_VAR                                                 !2
         24        SEND_VAR                                                 !0
         25        SEND_VAR                                                 !1
         26        DO_FCALL                                      0  $10     
         27        SEND_VAR                                                 $10
         28        DO_ICALL                                                 
   75    29        ECHO                                                     '%0A---%0A'
   76    30        INIT_FCALL                                               'var_export'
         31        INIT_FCALL                                               'skipkeys'
         32        SEND_VAR                                                 !2
         33        SEND_VAR                                                 !0
         34        SEND_VAR                                                 !1
         35        DO_FCALL                                      0  $12     
         36        SEND_VAR                                                 $12
         37        DO_ICALL                                                 
   77    38        ECHO                                                     '%0A---%0A'
   78    39        INIT_FCALL                                               'var_export'
         40        INIT_FCALL                                               'unsetkeys'
         41        SEND_VAR                                                 !2
         42        SEND_VAR                                                 !0
         43        SEND_VAR                                                 !1
         44        DO_FCALL                                      0  $14     
         45        SEND_VAR                                                 $14
         46        DO_ICALL                                                 
         47      > RETURN                                                   1

Function diffkeys:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Mss8J
function name:  diffKeys
number of ops:  16
compiled vars:  !0 = $timings, !1 = $starttime, !2 = $endtime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   33     3        INIT_FCALL                                               'array_diff_key'
          4        SEND_VAR                                                 !0
          5        INIT_FCALL                                               'array_flip'
          6        INIT_FCALL                                               'range'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
         11        DO_ICALL                                         $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                         $5      
         14      > RETURN                                                   $5
   34    15*     > RETURN                                                   null

End of function diffkeys

Function splicekeys:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Mss8J
function name:  spliceKeys
number of ops:  11
compiled vars:  !0 = $timings, !1 = $starttime, !2 = $endtime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   37     3        INIT_FCALL                                               'array_splice'
          4        SEND_REF                                                 !0
          5        SEND_VAR                                                 !1
          6        SUB                                              ~3      !2, !1
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                                 
   38     9      > RETURN                                                   !0
   40    10*     > RETURN                                                   null

End of function splicekeys

Function slicekeys:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Mss8J
function name:  sliceKeys
number of ops:  19
compiled vars:  !0 = $timings, !1 = $starttime, !2 = $endtime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   43     3        INIT_FCALL                                               'array_merge'
   44     4        INIT_FCALL                                               'array_slice'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 0
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
   45    10        INIT_FCALL                                               'array_slice'
         11        SEND_VAR                                                 !0
         12        ADD                                              ~4      !2, 1
         13        SEND_VAL                                                 ~4
         14        DO_ICALL                                         $5      
         15        SEND_VAR                                                 $5
   43    16        DO_ICALL                                         $6      
   45    17      > RETURN                                                   $6
   47    18*     > RETURN                                                   null

End of function slicekeys

Function skipkeys:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/Mss8J
function name:  skipKeys
number of ops:  19
compiled vars:  !0 = $timings, !1 = $starttime, !2 = $endtime, !3 = $result, !4 = $timing, !5 = $military
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   50     3        ASSIGN                                                   !3, <array>
   51     4      > FE_RESET_R                                       $7      !0, ->16
          5    > > FE_FETCH_R                                       ~8      $7, !4, ->16
          6    >   ASSIGN                                                   !5, ~8
   52     7        IS_SMALLER_OR_EQUAL                              ~10     !1, !5
          8      > JMPZ_EX                                          ~10     ~10, ->11
          9    >   IS_SMALLER_OR_EQUAL                              ~11     !5, !2
         10        BOOL                                             ~10     ~11
         11    > > JMPZ                                                     ~10, ->13
   53    12    > > JMP                                                      ->5
   55    13    >   ASSIGN_DIM                                               !3, !5
         14        OP_DATA                                                  !4
   51    15      > JMP                                                      ->5
         16    >   FE_FREE                                                  $7
   57    17      > RETURN                                                   !3
   58    18*     > RETURN                                                   null

End of function skipkeys

Function unsetkeys:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
Branch analysis from position: 11
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/Mss8J
function name:  unsetKeys
number of ops:  17
compiled vars:  !0 = $timings, !1 = $starttime, !2 = $endtime, !3 = $result, !4 = $timing, !5 = $military
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   61     3        ASSIGN                                                   !3, <array>
   62     4      > FE_RESET_R                                       $7      !0, ->14
          5    > > FE_FETCH_R                                       ~8      $7, !4, ->14
          6    >   ASSIGN                                                   !5, ~8
   63     7        IS_SMALLER_OR_EQUAL                              ~10     !1, !5
          8      > JMPZ_EX                                          ~10     ~10, ->11
          9    >   IS_SMALLER_OR_EQUAL                              ~11     !5, !2
         10        BOOL                                             ~10     ~11
         11    > > JMPZ                                                     ~10, ->13
   64    12    >   UNSET_DIM                                                !0, !5
   62    13    > > JMP                                                      ->5
         14    >   FE_FREE                                                  $7
   67    15      > RETURN                                                   !0
   68    16*     > RETURN                                                   null

End of function unsetkeys

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.57 ms | 1019 KiB | 25 Q