3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 'lvl1-A' => [ 'lvl2' => [ 'lvl3' => 'done' ], ], 'lvl1-B' => 'done', ]; function traverse( \Traversable $it ): void { while ( $it->valid() ) { $it->hasChildren() ? print "{$it->key()} => \n" and traverse( $it->getChildren() ) : print "{$it->key()} => {$it->current()}\n"; $it->next(); } } $it = new \RecursiveArrayIterator( $arr ); $it->rewind(); traverse( $it ); print 'Done.';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cGtoi
function name:  (null)
number of ops:  12
compiled vars:  !0 = $arr, !1 = $it
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        NEW                                              $3      'RecursiveArrayIterator'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
   22     5        INIT_METHOD_CALL                                         !1, 'rewind'
          6        DO_FCALL                                      0          
   23     7        INIT_FCALL                                               'traverse'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0          
   24    10        ECHO                                                     'Done.'
         11      > RETURN                                                   1

Function traverse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 2
Branch analysis from position: 34
Branch analysis from position: 2
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 2
Branch analysis from position: 34
Branch analysis from position: 2
filename:       /in/cGtoi
function name:  traverse
number of ops:  35
compiled vars:  !0 = $it
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1      > JMP                                                      ->31
   14     2    >   INIT_METHOD_CALL                                         !0, 'hasChildren'
          3        DO_FCALL                                      0  $1      
          4      > JMPZ                                                     $1, ->18
   15     5    >   INIT_METHOD_CALL                                         !0, 'key'
          6        DO_FCALL                                      0  $2      
          7        NOP                                                      
          8        FAST_CONCAT                                      ~3      $2, '+%3D%3E+%0A'
          9        ECHO                                                     ~3
         10        INIT_FCALL_BY_NAME                                       'traverse'
         11        INIT_METHOD_CALL                                         !0, 'getChildren'
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR_NO_REF_EX                                       $4
         14        DO_FCALL                                      0  $5      
         15        BOOL                                             ~6      $5
         16        QM_ASSIGN                                        ~7      ~6
         17      > JMP                                                      ->28
   16    18    >   INIT_METHOD_CALL                                         !0, 'key'
         19        DO_FCALL                                      0  $8      
         20        ROPE_INIT                                     4  ~11     $8
         21        ROPE_ADD                                      1  ~11     ~11, '+%3D%3E+'
         22        INIT_METHOD_CALL                                         !0, 'current'
         23        DO_FCALL                                      0  $9      
         24        ROPE_ADD                                      2  ~11     ~11, $9
         25        ROPE_END                                      3  ~10     ~11, '%0A'
         26        ECHO                                                     ~10
         27        QM_ASSIGN                                        ~7      1
         28    >   FREE                                                     ~7
   17    29        INIT_METHOD_CALL                                         !0, 'next'
         30        DO_FCALL                                      0          
   13    31    >   INIT_METHOD_CALL                                         !0, 'valid'
         32        DO_FCALL                                      0  $14     
         33      > JMPNZ                                                    $14, ->2
   19    34    > > RETURN                                                   null

End of function traverse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.21 ms | 1016 KiB | 14 Q