3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = array( 0, array( 0, 1, array( 0, 1, 2, array( 0, 1, 2, 3, array("the end") ) ) ) ); $recursive_array_iterator = new RecursiveArrayIterator($myArray); iterator_apply($recursive_array_iterator, 'traverseRecursiveArray', array($recursive_array_iterator)); $i = 0; function traverseRecursiveArray($iterator) { global $i; while ($iterator->valid()) { if ($iterator->hasChildren()) { traverseRecursiveArray($iterator->getChildren()); } else { echo $iterator->key() . ' => ' . $iterator->current() . PHP_EOL; } $iterator->current = "d"; $iterator->next(); } } iterator_apply($recursive_array_iterator, 'traverseRecursiveArray', array($recursive_array_iterator));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aj7AC
function name:  (null)
number of ops:  19
compiled vars:  !0 = $myArray, !1 = $recursive_array_iterator, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   23     1        NEW                                              $4      'RecursiveArrayIterator'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   24     5        INIT_FCALL                                               'iterator_apply'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 'traverseRecursiveArray'
          8        INIT_ARRAY                                       ~7      !1
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                                 
   26    11        ASSIGN                                                   !2, 0
   45    12        INIT_FCALL                                               'iterator_apply'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 'traverseRecursiveArray'
         15        INIT_ARRAY                                       ~10     !1
         16        SEND_VAL                                                 ~10
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function traverserecursivearray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 3
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 3
Branch analysis from position: 27
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 3
Branch analysis from position: 27
Branch analysis from position: 3
filename:       /in/aj7AC
function name:  traverseRecursiveArray
number of ops:  28
compiled vars:  !0 = $iterator, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        BIND_GLOBAL                                              !1, 'i'
   32     2      > JMP                                                      ->24
   33     3    >   INIT_METHOD_CALL                                         !0, 'hasChildren'
          4        DO_FCALL                                      0  $2      
          5      > JMPZ                                                     $2, ->12
   34     6    >   INIT_FCALL_BY_NAME                                       'traverseRecursiveArray'
          7        INIT_METHOD_CALL                                         !0, 'getChildren'
          8        DO_FCALL                                      0  $3      
          9        SEND_VAR_NO_REF_EX                                       $3
         10        DO_FCALL                                      0          
         11      > JMP                                                      ->20
   36    12    >   INIT_METHOD_CALL                                         !0, 'key'
         13        DO_FCALL                                      0  $5      
         14        CONCAT                                           ~6      $5, '+%3D%3E+'
         15        INIT_METHOD_CALL                                         !0, 'current'
         16        DO_FCALL                                      0  $7      
         17        CONCAT                                           ~8      ~6, $7
         18        CONCAT                                           ~9      ~8, '%0A'
         19        ECHO                                                     ~9
   39    20    >   ASSIGN_OBJ                                               !0, 'current'
         21        OP_DATA                                                  'd'
   41    22        INIT_METHOD_CALL                                         !0, 'next'
         23        DO_FCALL                                      0          
   32    24    >   INIT_METHOD_CALL                                         !0, 'valid'
         25        DO_FCALL                                      0  $12     
         26      > JMPNZ                                                    $12, ->3
   43    27    > > RETURN                                                   null

End of function traverserecursivearray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.1 ms | 1400 KiB | 15 Q