3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [["b" => "loc04", "c" => ["administrator" => "administrator"]]]; $arr[] = ["b" => "loc23", "c" => ["administrator" => "administrator", "publisher" => "publisher"]]; $arr[] = ["b" => "loc12", "c" => ["publisher" => "publisher", "viewer" => "viewer"]]; $role = "administrator"; //$a = array_filter($arr, function ($e) use ($role) {return in_array($role, $e["c"]);}); $a = array_filter($arr, function ($e) use ($role) {return isset($e["c"][$role]);}); print_r($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WpQQt
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arr, !1 = $role, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN_DIM                                               !0
          2        OP_DATA                                                  <array>
    5     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  <array>
    6     5        ASSIGN                                                   !1, 'administrator'
    9     6        INIT_FCALL                                               'array_filter'
          7        SEND_VAR                                                 !0
          8        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          9        BIND_LEXICAL                                             ~7, !1
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !2, $8
   11    13        INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
         16      > 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/WpQQt
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $e, !1 = $role
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_IS                                     ~2      !0, 'c'
          3        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      ~2, !1
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.75 ms | 999 KiB | 15 Q