3v4l.org

run code in 300+ PHP versions simultaneously
<?php $certificates = array( array('num' => '111', 'name' => 'cert1'), array('num' => '222', 'name' => 'cert2') ); //получаем массив который содержит 'name' => 'cert2' class ArrayFilter { private $array; private $field; private $value; function __construct($array, $field, $value) { $this->array = $array; $this->field = $field; $this->value = $value; } function dataCorrect() { $arr = $this->array; $field = $this->field; $val = $this->value; return $arr[$field] == $val; } } $field = 'name'; $value = 'cert1'; $out = array_filter( $certificates, array(new ArrayFilter($certificates, $field, $value), 'dataCorrect') ); print_r($out);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X5ZGY
function name:  (null)
number of ops:  19
compiled vars:  !0 = $certificates, !1 = $field, !2 = $value, !3 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   30     1        ASSIGN                                                   !1, 'name'
   31     2        ASSIGN                                                   !2, 'cert1'
   33     3        INIT_FCALL                                               'array_filter'
   34     4        SEND_VAR                                                 !0
   35     5        NEW                                              $7      'ArrayFilter'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAR_EX                                              !1
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0          
         10        INIT_ARRAY                                       ~9      $7
         11        ADD_ARRAY_ELEMENT                                ~9      'dataCorrect'
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
   33    14        ASSIGN                                                   !3, $10
   38    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

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

End of function __construct

Function datacorrect:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X5ZGY
function name:  dataCorrect
number of ops:  10
compiled vars:  !0 = $arr, !1 = $field, !2 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~3      'array'
          1        ASSIGN                                                   !0, ~3
   23     2        FETCH_OBJ_R                                      ~5      'field'
          3        ASSIGN                                                   !1, ~5
   24     4        FETCH_OBJ_R                                      ~7      'value'
          5        ASSIGN                                                   !2, ~7
   25     6        FETCH_DIM_R                                      ~9      !0, !1
          7        IS_EQUAL                                         ~10     !2, ~9
          8      > RETURN                                                   ~10
   26     9*     > RETURN                                                   null

End of function datacorrect

End of class ArrayFilter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.76 ms | 1400 KiB | 17 Q