3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = ['3' => '4', '4' => '5', '1' => '2']; $allowed = ['1', '2', '3']; $flipAllowed = array_flip($allowed); var_export( array_replace( array_intersect_key($flipAllowed, $input), // filtered allowed array_intersect_key($input, $flipAllowed) // filtered input ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ogEN7
function name:  (null)
number of ops:  22
compiled vars:  !0 = $input, !1 = $allowed, !2 = $flipAllowed
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, <array>
    6     2        INIT_FCALL                                                   'array_flip'
          3        SEND_VAR                                                     !1
          4        DO_ICALL                                             $5      
          5        ASSIGN                                                       !2, $5
    8     6        INIT_FCALL                                                   'var_export'
    9     7        INIT_FCALL                                                   'array_replace'
   10     8        INIT_FCALL                                                   'array_intersect_key'
          9        SEND_VAR                                                     !2
         10        SEND_VAR                                                     !0
         11        DO_ICALL                                             $7      
         12        SEND_VAR                                                     $7
   11    13        INIT_FCALL                                                   'array_intersect_key'
         14        SEND_VAR                                                     !0
         15        SEND_VAR                                                     !2
         16        DO_ICALL                                             $8      
         17        SEND_VAR                                                     $8
    9    18        DO_ICALL                                             $9      
   11    19        SEND_VAR                                                     $9
    8    20        DO_ICALL                                                     
   13    21      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.78 ms | 1860 KiB | 17 Q