3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = ['en' => ['em' => null]]; $array2 = ['en' => ['em' => 'RESULT'], 'something' => ['somekey1' => 'somevalue1', 'somekey2' => 'somevalue2']]; function get_result(array $arr) { $args = func_get_args(); unset($args[0]); if (!$args) { return; } foreach ($args as $arg) { if (!isset($arr[$arg])) { return; } $arr = $arr[$arg]; } return $arr; } var_dump( get_result($array2, 'en', 'em') ); var_dump( get_result($array2, 'en') ); var_dump( get_result($array2, 'something', 'somekey2') );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vmJui
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array1, !1 = $array2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
   21     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'get_result'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 'en'
          6        SEND_VAL                                                 'em'
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   22    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'get_result'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 'en'
         14        DO_FCALL                                      0  $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                                 
   23    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'get_result'
         19        SEND_VAR                                                 !1
         20        SEND_VAL                                                 'something'
         21        SEND_VAL                                                 'somekey2'
         22        DO_FCALL                                      0  $8      
         23        SEND_VAR                                                 $8
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Function get_result:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
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
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/vmJui
function name:  get_result
number of ops:  20
compiled vars:  !0 = $arr, !1 = $args, !2 = $arg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        FUNC_GET_ARGS                                    ~3      
          2        ASSIGN                                                   !1, ~3
    8     3        UNSET_DIM                                                !1, 0
    9     4        BOOL_NOT                                         ~5      !1
          5      > JMPZ                                                     ~5, ->7
   10     6    > > RETURN                                                   null
   12     7    > > FE_RESET_R                                       $6      !1, ->17
          8    > > FE_FETCH_R                                               $6, !2, ->17
   13     9    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !0, !2
         10        BOOL_NOT                                         ~8      ~7
         11      > JMPZ                                                     ~8, ->14
   14    12    >   FE_FREE                                                  $6
         13      > RETURN                                                   null
   16    14    >   FETCH_DIM_R                                      ~9      !0, !2
         15        ASSIGN                                                   !0, ~9
   12    16      > JMP                                                      ->8
         17    >   FE_FREE                                                  $6
   18    18      > RETURN                                                   !0
   19    19*     > RETURN                                                   null

End of function get_result

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.34 ms | 1394 KiB | 18 Q