3v4l.org

run code in 300+ PHP versions simultaneously
<?php $A = [3,45,67,8]; $B = [ 1 => [1,6,8], 2 => [5,67,3,4,5,66,6], 3 => [55,56,57,58], 4 => [45,80,81,82] ]; $A = array_flip($A); // prepare for key comparisons $result = []; foreach ($B as $key => $haystack) { if (array_intersect_key(array_flip($haystack), $A)) { $result[] = $key; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 21
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 21
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/6aLJD
function name:  (null)
number of ops:  26
compiled vars:  !0 = $A, !1 = $B, !2 = $result, !3 = $haystack, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    9     2        INIT_FCALL                                               'array_flip'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !0, $7
   10     6        ASSIGN                                                   !2, <array>
   11     7      > FE_RESET_R                                       $10     !1, ->21
          8    > > FE_FETCH_R                                       ~11     $10, !3, ->21
          9    >   ASSIGN                                                   !4, ~11
   12    10        INIT_FCALL                                               'array_intersect_key'
         11        INIT_FCALL                                               'array_flip'
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $13     
         14        SEND_VAR                                                 $13
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $14     
         17      > JMPZ                                                     $14, ->20
   13    18    >   ASSIGN_DIM                                               !2
         19        OP_DATA                                                  !4
   11    20    > > JMP                                                      ->8
         21    >   FE_FREE                                                  $10
   16    22        INIT_FCALL                                               'var_export'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.26 ms | 1002 KiB | 16 Q