3v4l.org

run code in 300+ PHP versions simultaneously
<?php function filter($array, $like, $kol) { $filtered = array_filter($array, function ($item) use ($kol, $like) { if (array_key_exists($kol, $item)) { return $item[$kol] === $like; } return false; }); return array_values($filtered); } $array = [ ["a" => "test"], ["b" => "test2"], ["c" => "test"] ]; print_r(filter($array, "test", "b")); print_r(filter($array, "test2", "b"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gEI5r
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'filter'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'test'
          5        SEND_VAL                                                 'b'
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   21     9        INIT_FCALL                                               'print_r'
         10        INIT_FCALL                                               'filter'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 'test2'
         13        SEND_VAL                                                 'b'
         14        DO_FCALL                                      0  $4      
         15        SEND_VAR                                                 $4
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gEI5r
function name:  filter
number of ops:  16
compiled vars:  !0 = $array, !1 = $like, !2 = $kol, !3 = $filtered
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !0
          5        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          6        BIND_LEXICAL                                             ~4, !2
          7        BIND_LEXICAL                                             ~4, !1
    9     8        SEND_VAL                                                 ~4
    4     9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !3, $5
   11    11        INIT_FCALL                                               'array_values'
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $7      
         14      > RETURN                                                   $7
   12    15*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gEI5r
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $item, !1 = $kol, !2 = $like
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
    5     3        ARRAY_KEY_EXISTS                                         !1, !0
          4      > JMPZ                                                     ~3, ->8
    6     5    >   FETCH_DIM_R                                      ~4      !0, !1
          6        IS_IDENTICAL                                     ~5      !2, ~4
          7      > RETURN                                                   ~5
    8     8    > > RETURN                                                   <false>
    9     9*     > RETURN                                                   null

End of Dynamic Function 0

End of function filter

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.72 ms | 962 KiB | 18 Q