3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruits_arr = [ ['id' => 213, 'fruit' => 'banana'], ['id' => 438, 'fruit' => 'apple'], ['id' => 154, 'fruit' => 'peach'], ]; $ids_arr = [213, 154]; $selected_fruits = array_filter($fruits_arr, function ($el) use ($ids_arr) { return in_array($el['id'], $ids_arr, true); }); print_r($selected_fruits); $selected_fruits = array_filter($fruits_arr, fn ($el) => in_array($el['id'], $ids_arr, true)); print_r($selected_fruits);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4UC41
function name:  (null)
number of ops:  23
compiled vars:  !0 = $fruits_arr, !1 = $ids_arr, !2 = $selected_fruits
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   11     2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          5        BIND_LEXICAL                                             ~5, !1
   13     6        SEND_VAL                                                 ~5
   11     7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
   15     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   17    12        INIT_FCALL                                               'array_filter'
         13        SEND_VAR                                                 !0
         14        DECLARE_LAMBDA_FUNCTION                          ~9      [1]
         15        BIND_LEXICAL                                             ~9, !1
         16        SEND_VAL                                                 ~9
         17        DO_ICALL                                         $10     
         18        ASSIGN                                                   !2, $10
   19    19        INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                                 
         22      > 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/4UC41
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $el, !1 = $ids_arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   12     2        INIT_FCALL                                               'in_array'
          3        FETCH_DIM_R                                      ~2      !0, 'id'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   13     9*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4UC41
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $el, !1 = $ids_arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'in_array'
          3        FETCH_DIM_R                                      ~2      !0, 'id'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
          9*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.06 ms | 1017 KiB | 16 Q