3v4l.org

run code in 500+ PHP versions simultaneously
<?php $my_array = ['A1'=>'Data1','A2'=>'Data2','A3'=>'Data3','A4'=>'Data4','A5'=>'Data5']; $allowed = ['0'=>'A1','1'=>'A2','2'=>'A3']; $filtered = array_filter( $my_array, function ($key) use ($allowed) { return in_array($key, $allowed); }, ARRAY_FILTER_USE_KEY ); var_dump($filtered);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZvkJb
function name:  (null)
number of ops:  14
compiled vars:  !0 = $my_array, !1 = $allowed, !2 = $filtered
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, <array>
    5     2        INIT_FCALL                                                   'array_filter'
    6     3        SEND_VAR                                                     !0
    7     4        DECLARE_LAMBDA_FUNCTION                              ~5      [0]
          5        BIND_LEXICAL                                                 ~5, !1
    9     6        SEND_VAL                                                     ~5
   10     7        SEND_VAL                                                     2
    5     8        DO_ICALL                                             $6      
          9        ASSIGN                                                       !2, $6
   13    10        INIT_FCALL                                                   'var_dump'
         11        SEND_VAR                                                     !2
         12        DO_ICALL                                                     
         13      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZvkJb
function name:  {closure:/in/ZvkJb:7}
number of ops:  5
compiled vars:  !0 = $key, !1 = $allowed
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
    8     2        FRAMELESS_ICALL_2                in_array            ~2      !0, !1
          3      > RETURN                                                       ~2
    9     4*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.68 ms | 2131 KiB | 15 Q