3v4l.org

run code in 300+ PHP versions simultaneously
<?php $f = []; $f['Kitchen']['Dishes']['Mantovarka']=3; $f['Kitchen']['Dishes']['Castrool']=91; $f['Kitchen']['Dishes']['Separator']=10; $f['Kitchen']['Product']=18; $f['Kitchen']['Textile']=19; $f['Kitchen']['Blue things One2']['Juicemaker']=25; $f['Kitchen']['Blue things One']['Freegener']=13; $f['Kitchen']['Blue things']['Microwave']=4; $f['Kitchen']['Blue things']['Iron']=24; function findKeyPath($arr, $key, $path = '') { foreach($arr as $k => $value) { if(is_array($arr[$k])) { $ret = findKeyPath($arr[$k], $key, $path.$k.','); if(is_array($ret)) { return $ret; } }else if($k == $key) { return explode(',', $path.$key); } } return null; } print_r(findKeyPath($f, 'Juicemaker'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJD7q
function name:  (null)
number of ops:  43
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        FETCH_DIM_W                                      $2      !0, 'Kitchen'
          2        FETCH_DIM_W                                      $3      $2, 'Dishes'
          3        ASSIGN_DIM                                               $3, 'Mantovarka'
          4        OP_DATA                                                  3
    6     5        FETCH_DIM_W                                      $5      !0, 'Kitchen'
          6        FETCH_DIM_W                                      $6      $5, 'Dishes'
          7        ASSIGN_DIM                                               $6, 'Castrool'
          8        OP_DATA                                                  91
    7     9        FETCH_DIM_W                                      $8      !0, 'Kitchen'
         10        FETCH_DIM_W                                      $9      $8, 'Dishes'
         11        ASSIGN_DIM                                               $9, 'Separator'
         12        OP_DATA                                                  10
    8    13        FETCH_DIM_W                                      $11     !0, 'Kitchen'
         14        ASSIGN_DIM                                               $11, 'Product'
         15        OP_DATA                                                  18
    9    16        FETCH_DIM_W                                      $13     !0, 'Kitchen'
         17        ASSIGN_DIM                                               $13, 'Textile'
         18        OP_DATA                                                  19
   10    19        FETCH_DIM_W                                      $15     !0, 'Kitchen'
         20        FETCH_DIM_W                                      $16     $15, 'Blue+things+One2'
         21        ASSIGN_DIM                                               $16, 'Juicemaker'
         22        OP_DATA                                                  25
   11    23        FETCH_DIM_W                                      $18     !0, 'Kitchen'
         24        FETCH_DIM_W                                      $19     $18, 'Blue+things+One'
         25        ASSIGN_DIM                                               $19, 'Freegener'
         26        OP_DATA                                                  13
   12    27        FETCH_DIM_W                                      $21     !0, 'Kitchen'
         28        FETCH_DIM_W                                      $22     $21, 'Blue+things'
         29        ASSIGN_DIM                                               $22, 'Microwave'
         30        OP_DATA                                                  4
   13    31        FETCH_DIM_W                                      $24     !0, 'Kitchen'
         32        FETCH_DIM_W                                      $25     $24, 'Blue+things'
         33        ASSIGN_DIM                                               $25, 'Iron'
         34        OP_DATA                                                  24
   29    35        INIT_FCALL                                               'print_r'
         36        INIT_FCALL                                               'findkeypath'
         37        SEND_VAR                                                 !0
         38        SEND_VAL                                                 'Juicemaker'
         39        DO_FCALL                                      0  $27     
         40        SEND_VAR                                                 $27
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Function findkeypath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 34
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 34
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 33
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/YJD7q
function name:  findKeyPath
number of ops:  37
compiled vars:  !0 = $arr, !1 = $key, !2 = $path, !3 = $value, !4 = $k, !5 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      ''
   16     3      > FE_RESET_R                                       $6      !0, ->34
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->34
          5    >   ASSIGN                                                   !4, ~7
   17     6        FETCH_DIM_R                                      ~9      !0, !4
          7        TYPE_CHECK                                  128          ~9
          8      > JMPZ                                                     ~10, ->24
   18     9    >   INIT_FCALL_BY_NAME                                       'findKeyPath'
         10        CHECK_FUNC_ARG                                           
         11        FETCH_DIM_FUNC_ARG                               $11     !0, !4
         12        SEND_FUNC_ARG                                            $11
         13        SEND_VAR_EX                                              !1
         14        CONCAT                                           ~12     !2, !4
         15        CONCAT                                           ~13     ~12, '%2C'
         16        SEND_VAL_EX                                              ~13
         17        DO_FCALL                                      0  $14     
         18        ASSIGN                                                   !5, $14
   19    19        TYPE_CHECK                                  128          !5
         20      > JMPZ                                                     ~16, ->23
   20    21    >   FE_FREE                                                  $6
         22      > RETURN                                                   !5
   17    23    > > JMP                                                      ->33
   22    24    >   IS_EQUAL                                                 !4, !1
         25      > JMPZ                                                     ~17, ->33
   23    26    >   INIT_FCALL                                               'explode'
         27        SEND_VAL                                                 '%2C'
         28        CONCAT                                           ~18     !2, !1
         29        SEND_VAL                                                 ~18
         30        DO_ICALL                                         $19     
         31        FE_FREE                                                  $6
         32      > RETURN                                                   $19
   16    33    > > JMP                                                      ->4
         34    >   FE_FREE                                                  $6
   26    35      > RETURN                                                   null
   27    36*     > RETURN                                                   null

End of function findkeypath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.19 ms | 1012 KiB | 16 Q