3v4l.org

run code in 300+ PHP versions simultaneously
<?php $GET = [ "randomekey1" => "valueX", "randomkey2" => "valueY", "acceptedkey1" => "valueZ", "randomkey3" => "valueA", "acceptedkey2" => "valueB" ]; $whitelist = [ "acceptedkey1", "acceptedkey2", "acceptedkey3", ]; var_export( (bool)array_diff_key($GET, array_flip($whitelist)) ); echo "\n---\n"; $hasNotWhitelisted = false; $lookup = array_flip($whitelist); foreach ($GET as $key => $value) { if (isset($lookup[$key])) { $hasNotWhitelisted = true; break; } } var_export($hasNotWhitelisted); echo "\n---\n"; function hasNotWhitelisted($array, $whitelist): bool { $lookup = array_flip($whitelist); foreach ($array as $key => $value) { if (isset($lookup[$key])) { return true; } } return false; } var_export(hasNotWhitelisted($GET, $whitelist));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 27
Branch analysis from position: 27
filename:       /in/JQXUD
function name:  (null)
number of ops:  40
compiled vars:  !0 = $GET, !1 = $whitelist, !2 = $hasNotWhitelisted, !3 = $lookup, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   17     2        INIT_FCALL                                               'var_export'
   18     3        INIT_FCALL                                               'array_diff_key'
          4        SEND_VAR                                                 !0
          5        INIT_FCALL                                               'array_flip'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $8      
          8        SEND_VAR                                                 $8
          9        DO_ICALL                                         $9      
         10        BOOL                                             ~10     $9
         11        SEND_VAL                                                 ~10
   17    12        DO_ICALL                                                 
   21    13        ECHO                                                     '%0A---%0A'
   23    14        ASSIGN                                                   !2, <false>
   24    15        INIT_FCALL                                               'array_flip'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !3, $13
   25    19      > FE_RESET_R                                       $15     !0, ->27
         20    > > FE_FETCH_R                                       ~16     $15, !4, ->27
         21    >   ASSIGN                                                   !5, ~16
   26    22        ISSET_ISEMPTY_DIM_OBJ                         0          !3, !5
         23      > JMPZ                                                     ~18, ->26
   27    24    >   ASSIGN                                                   !2, <true>
   28    25      > JMP                                                      ->27
   25    26    > > JMP                                                      ->20
         27    >   FE_FREE                                                  $15
   31    28        INIT_FCALL                                               'var_export'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                                 
   33    31        ECHO                                                     '%0A---%0A'
   44    32        INIT_FCALL                                               'var_export'
         33        INIT_FCALL                                               'hasnotwhitelisted'
         34        SEND_VAR                                                 !0
         35        SEND_VAR                                                 !1
         36        DO_FCALL                                      0  $21     
         37        SEND_VAR                                                 $21
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Function hasnotwhitelisted:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/JQXUD
function name:  hasNotWhitelisted
number of ops:  18
compiled vars:  !0 = $array, !1 = $whitelist, !2 = $lookup, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   36     2        INIT_FCALL                                               'array_flip'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   37     6      > FE_RESET_R                                       $7      !0, ->14
          7    > > FE_FETCH_R                                       ~8      $7, !3, ->14
          8    >   ASSIGN                                                   !4, ~8
   38     9        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !4
         10      > JMPZ                                                     ~10, ->13
   39    11    >   FE_FREE                                                  $7
         12      > RETURN                                                   <true>
   37    13    > > JMP                                                      ->7
         14    >   FE_FREE                                                  $7
   42    15      > RETURN                                                   <false>
   43    16*       VERIFY_RETURN_TYPE                                       
         17*     > RETURN                                                   null

End of function hasnotwhitelisted

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.71 ms | 1020 KiB | 17 Q