3v4l.org

run code in 500+ PHP versions simultaneously
<?php $reference = [ 'a' => 'this is A', 'b' => 'here is B', 'c' => 'C here', 'd' => 'finally, d', ]; $indexesToKeep = [1, 3]; $mapKeysToIndexes = array_flip(array_keys($reference)); $keysToKeep = array_intersect($mapKeysToIndexes, $indexesToKeep); var_export(array_intersect_key($reference, $keysToKeep));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a4q1R
function name:  (null)
number of ops:  22
compiled vars:  !0 = $reference, !1 = $indexesToKeep, !2 = $mapKeysToIndexes, !3 = $keysToKeep
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   10     1        ASSIGN                                                       !1, <array>
   11     2        INIT_FCALL                                                   'array_flip'
          3        INIT_FCALL                                                   'array_keys'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $6      
          6        SEND_VAR                                                     $6
          7        DO_ICALL                                             $7      
          8        ASSIGN                                                       !2, $7
   12     9        INIT_FCALL                                                   'array_intersect'
         10        SEND_VAR                                                     !2
         11        SEND_VAR                                                     !1
         12        DO_ICALL                                             $9      
         13        ASSIGN                                                       !3, $9
   13    14        INIT_FCALL                                                   'var_export'
         15        INIT_FCALL                                                   'array_intersect_key'
         16        SEND_VAR                                                     !0
         17        SEND_VAR                                                     !3
         18        DO_ICALL                                             $11     
         19        SEND_VAR                                                     $11
         20        DO_ICALL                                                     
         21      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
128.68 ms | 481 KiB | 12 Q