3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 'USA' => [ 'Alabama' => [ 'Montgomery', 'Birmingham' ], 'Arizona' => [ 'Phoenix', 'Mesa', 'Gilbert' ] ], 'Germany' => [ 'West Germany' => [ 'Bonn', 'Cologne' ] ] ]; $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr)); $keys = array(); foreach ($iterator as $key => $value) { // Build long key name based on parent keys $key = [$key]; for ($i = $iterator->getDepth() - 1; $i >= 0; $i--) { //$key = $iterator->getSubIterator($i)->key() . '_' . $key; array_unshift($key, $iterator->getSubIterator($i)->key()); } $key[] = $value; $keys[] = $key; } var_export($keys);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 36
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 36
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
Branch analysis from position: 19
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/ueSBB
function name:  (null)
number of ops:  41
compiled vars:  !0 = $arr, !1 = $iterator, !2 = $keys, !3 = $value, !4 = $key, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   26     1        NEW                                              $7      'RecursiveIteratorIterator'
          2        NEW                                              $8      'RecursiveArrayIterator'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $8
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $7
   27     8        ASSIGN                                                   !2, <array>
   28     9      > FE_RESET_R                                       $13     !1, ->36
         10    > > FE_FETCH_R                                       ~14     $13, !3, ->36
         11    >   ASSIGN                                                   !4, ~14
   30    12        INIT_ARRAY                                       ~16     !4
         13        ASSIGN                                                   !4, ~16
   31    14        INIT_METHOD_CALL                                         !1, 'getDepth'
         15        DO_FCALL                                      0  $18     
         16        SUB                                              ~19     $18, 1
         17        ASSIGN                                                   !5, ~19
         18      > JMP                                                      ->29
   33    19    >   INIT_FCALL                                               'array_unshift'
         20        SEND_REF                                                 !4
         21        INIT_METHOD_CALL                                         !1, 'getSubIterator'
         22        SEND_VAR_EX                                              !5
         23        DO_FCALL                                      0  $21     
         24        INIT_METHOD_CALL                                         $21, 'key'
         25        DO_FCALL                                      0  $22     
         26        SEND_VAR                                                 $22
         27        DO_ICALL                                                 
   31    28        PRE_DEC                                                  !5
         29    >   IS_SMALLER_OR_EQUAL                                      0, !5
         30      > JMPNZ                                                    ~25, ->19
   35    31    >   ASSIGN_DIM                                               !4
         32        OP_DATA                                                  !3
   36    33        ASSIGN_DIM                                               !2
         34        OP_DATA                                                  !4
   28    35      > JMP                                                      ->10
         36    >   FE_FREE                                                  $13
   38    37        INIT_FCALL                                               'var_export'
         38        SEND_VAR                                                 !2
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.78 ms | 1392 KiB | 17 Q