3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Stuff { public static function getArrayValueByPath($array, $path) { $path = (array) array_filter( $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/0Puj4
function name:  (null)
number of ops:  12
compiled vars:  !0 = $data, !1 = $iteration, !2 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, 0
   18     2        INIT_ARRAY                                       ~5      !1
          3        ASSIGN                                                   !2, ~5
   19     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 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0Puj4
function name:  getArrayValueByPath
number of ops:  25
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        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $3      
          5        CAST                                          7  ~4      $3
          6        ASSIGN                                                   !1, ~4
    7     7        ISSET_ISEMPTY_CV                                 ~6      !1
          8        BOOL_NOT                                         ~7      ~6
          9      > JMPZ                                                     ~7, ->23
    8    10    > > FE_RESET_R                                       $8      !1, ->20
         11    > > FE_FETCH_R                                               $8, !2, ->20
         12    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !0, !2
         13        BOOL_NOT                                         ~10     ~9
         14      > JMPZ                                                     ~10, ->17
         15    >   FE_FREE                                                  $8
         16      > RETURN                                                   null
         17    >   FETCH_DIM_R                                      ~11     !0, !2
         18        ASSIGN                                                   !0, ~11
         19      > JMP                                                      ->11
         20    >   FE_FREE                                                  $8
    9    21      > RETURN                                                   !0
         22*       JMP                                                      ->24
   11    23    > > RETURN                                                   <false>
   13    24*     > RETURN                                                   null

End of function getarrayvaluebypath

End of class Stuff.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.44 ms | 1392 KiB | 17 Q