3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayFilters { private $array = array(); private $name; public function __construct($array, $name){ $this->array = $array; $this->name = $name; } public function name_is($arr){ return $arr['name'] == $this->name; } } $array1 = array( "a"=>array( 'name' => 'vasya' ,'second_name' => 'Vasilev' ), "b"=>array( 'name' => 'vasya2' ,'second_name' => 'Vasilev2' ), "c"=>array( 'name' => 'vasya3' ,'second_name' => 'Vasilev3' ), "d"=>array( 'name' => 'vasya4' ,'second_name' => 'Vasilev4' ), "e"=>array( 'name' => 'vasya5' ,'second_name' => 'Vasilev5' ) ); $name = 'vasya2'; //print_r(array_filter($array1, array(new ArrayFilters($array1, 'vasya2'), 'name_is'))); print_r(array_filter($array1, function($value) use ($name) { return $value['name'] == $name; }));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ErW59
function name:  (null)
number of ops:  12
compiled vars:  !0 = $array1, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   40     1        ASSIGN                                                   !1, 'vasya2'
   42     2        INIT_FCALL                                               'print_r'
          3        INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !0
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FErW59%3A42%240'
          6        BIND_LEXICAL                                             ~4, !1
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FErW59%3A42%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ErW59
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $value, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 'name'
          3        IS_EQUAL                                         ~3      !1, ~2
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FErW59%3A42%240

Class ArrayFilters:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ErW59
function name:  __construct
number of ops:  7
compiled vars:  !0 = $array, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN_OBJ                                               'array'
          3        OP_DATA                                                  !0
    8     4        ASSIGN_OBJ                                               'name'
          5        OP_DATA                                                  !1
    9     6      > RETURN                                                   null

End of function __construct

Function name_is:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ErW59
function name:  name_is
number of ops:  6
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        FETCH_DIM_R                                      ~1      !0, 'name'
          2        FETCH_OBJ_R                                      ~2      'name'
          3        IS_EQUAL                                         ~3      ~1, ~2
          4      > RETURN                                                   ~3
   14     5*     > RETURN                                                   null

End of function name_is

End of class ArrayFilters.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.63 ms | 1400 KiB | 17 Q