3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Stuff { public static function getArrayValueByPath($array, $path) { if( !empty( $path ) ) { foreach ( $path as $key ) { if( !isset( $array[$key] ) ) { return NULL; } $array = $array[$key]; } return $array; } else { return false; } } } $data = array( 0 => 'abc', 1 => '123'); $iteration = 0; $path = array( $iteration ); var_dump( Stuff::getArrayValueByPath( $data, $path ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cgp5D
function name:  (null)
number of ops:  12
compiled vars:  !0 = $data, !1 = $iteration, !2 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, 0
   16     2        INIT_ARRAY                                       ~5      !1
          3        ASSIGN                                                   !2, ~5
   17     4        INIT_FCALL                                               'var_dump'
          5        INIT_STATIC_METHOD_CALL                                  'Stuff', 'getArrayValueByPath'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !2
          8        DO_FCALL                                      0  $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Class Stuff:
Function getarrayvaluebypath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cgp5D
function name:  getArrayValueByPath
number of ops:  20
compiled vars:  !0 = $array, !1 = $path, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ISSET_ISEMPTY_CV                                 ~3      !1
          3        BOOL_NOT                                         ~4      ~3
          4      > JMPZ                                                     ~4, ->18
    6     5    > > FE_RESET_R                                       $5      !1, ->15
          6    > > FE_FETCH_R                                               $5, !2, ->15
          7    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, !2
          8        BOOL_NOT                                         ~7      ~6
          9      > JMPZ                                                     ~7, ->12
         10    >   FE_FREE                                                  $5
         11      > RETURN                                                   null
         12    >   FETCH_DIM_R                                      ~8      !0, !2
         13        ASSIGN                                                   !0, ~8
         14      > JMP                                                      ->6
         15    >   FE_FREE                                                  $5
    7    16      > RETURN                                                   !0
         17*       JMP                                                      ->19
    9    18    > > RETURN                                                   <false>
   11    19*     > RETURN                                                   null

End of function getarrayvaluebypath

End of class Stuff.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.62 ms | 1400 KiB | 15 Q