3v4l.org

run code in 300+ PHP versions simultaneously
<?php $itemx= [ 'Weapons'=>[ 'Sword'=> [ 'ID' => '1', 'Name' => 'Lurker', 'Value' => '12', 'Made' => 'Acient' ], 'Shield'=> [ 'ID' => '2', 'Name' => 'Obi', 'Value' => '22', 'Made' => 'Acient' ], 'Warhammer'=> [ 'ID' => '3', 'Name' => 'Clotch', 'Value' => '124', 'Made' => 'Acient' ] ], 'Drinks'=>[ 'Water'=> [ 'ID' => '4', 'Name' => 'Clean-water', 'Value' => '1', 'Made' => 'Acient' ], 'Wine'=> [ 'ID' => '5', 'Name' => 'Soff', 'Value' => '5', 'Made' => 'Acient' ], 'Vodka'=> [ 'ID' => '6', 'Name' => 'Laudur', 'Value' => '7', 'Made' => 'Acient' ] ] ]; $sub = null; $id = 4; $cat = array_find_key( $itemx, function ($set) use ($id, &$sub) { return ($sub = array_find_key( $set, fn($row) => $row['ID'] == $id )) !== null; } ); var_export([$sub => $itemx[$cat][$sub]]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7LrLS
function name:  (null)
number of ops:  18
compiled vars:  !0 = $itemx, !1 = $sub, !2 = $id, !3 = $cat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   51     1        ASSIGN                                                   !1, null
   52     2        ASSIGN                                                   !2, 4
   53     3        INIT_FCALL_BY_NAME                                       'array_find_key'
   54     4        SEND_VAR_EX                                              !0
   55     5        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          6        BIND_LEXICAL                                             ~7, !2
          7        BIND_LEXICAL                                             ~7, !1
   60     8        SEND_VAL_EX                                              ~7
   53     9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !3, $8
   62    11        INIT_FCALL                                               'var_export'
         12        FETCH_DIM_R                                      ~10     !0, !3
         13        FETCH_DIM_R                                      ~11     ~10, !1
         14        INIT_ARRAY                                       ~12     ~11, !1
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                                 
         17      > 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/7LrLS
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $set, !1 = $id, !2 = $sub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   56     3        INIT_FCALL_BY_NAME                                       'array_find_key'
   57     4        SEND_VAR_EX                                              !0
   58     5        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          6        BIND_LEXICAL                                             ~3, !1
   59     7        SEND_VAL_EX                                              ~3
   56     8        DO_FCALL                                      0  $4      
          9        ASSIGN                                           ~5      !2, $4
   59    10        TYPE_CHECK                                  1020  ~6      ~5
         11      > RETURN                                                   ~6
   60    12*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7LrLS
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $row, !1 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 'ID'
          3        IS_EQUAL                                         ~3      !1, ~2
          4      > RETURN                                                   ~3
   59     5*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.13 ms | 1005 KiB | 14 Q