3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_by_path($value, $path) { if (empty($path)) { return $value; } $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/7jfNq
function name:  (null)
number of ops:  7
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   20     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 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7jfNq
function name:  array_by_path
number of ops:  25
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        ISSET_ISEMPTY_CV                                         !1
          3      > JMPZ                                                     ~3, ->5
    5     4    > > RETURN                                                   !0
    7     5    >   INIT_FCALL                                               'array_shift'
          6        SEND_REF                                                 !1
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !2, $4
    8     9        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, !2
         10        BOOL_NOT                                         ~7      ~6
         11      > JMPZ                                                     ~7, ->14
         12    > > RETURN                                                   null
         13*       JMP                                                      ->23
    9    14    >   FETCH_DIM_R                                      ~8      !0, !2
         15        TYPE_CHECK                                  128          ~8
         16      > JMPZ                                                     ~9, ->23
         17    >   INIT_FCALL_BY_NAME                                       'array_by_path'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_DIM_FUNC_ARG                               $10     !0, !2
         20        SEND_FUNC_ARG                                            $10
         21        DO_FCALL                                      0  $11     
         22      > RETURN                                                   $11
   10    23    > > RETURN                                                   !0
   12    24*     > RETURN                                                   null

End of function array_by_path

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.72 ms | 1399 KiB | 16 Q