3v4l.org

run code in 300+ 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}
number of ops:  8
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        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
    9     7*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.25 ms | 1004 KiB | 16 Q