3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_by_path($value, $path) { $curr = array_shift($path); if (!isset($value[$curr])) { return null; } elseif (is_array($value[$curr])) { return array_by_path($value[$curr]); } return $value; } $test = array( 'wot' => array( 'mate' => 'hello' ) ); echo array_by_path($test, ['wot', 'mate']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g6A5r
function name:  (null)
number of ops:  7
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   17     1        INIT_FCALL                                               'array_by_path'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6      > RETURN                                                   1

Function array_by_path:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g6A5r
function name:  array_by_path
number of ops:  22
compiled vars:  !0 = $value, !1 = $path, !2 = $curr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'array_shift'
          3        SEND_REF                                                 !1
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !2, $3
    5     6        ISSET_ISEMPTY_DIM_OBJ                         0  ~5      !0, !2
          7        BOOL_NOT                                         ~6      ~5
          8      > JMPZ                                                     ~6, ->11
          9    > > RETURN                                                   null
         10*       JMP                                                      ->20
    6    11    >   FETCH_DIM_R                                      ~7      !0, !2
         12        TYPE_CHECK                                  128          ~7
         13      > JMPZ                                                     ~8, ->20
         14    >   INIT_FCALL_BY_NAME                                       'array_by_path'
         15        CHECK_FUNC_ARG                                           
         16        FETCH_DIM_FUNC_ARG                               $9      !0, !2
         17        SEND_FUNC_ARG                                            $9
         18        DO_FCALL                                      0  $10     
         19      > RETURN                                                   $10
    7    20    > > RETURN                                                   !0
    9    21*     > RETURN                                                   null

End of function array_by_path

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.16 ms | 1403 KiB | 16 Q