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 { $iterator->offsetSet($iterator->key, "d"); echo $iterator->key() . ' => ' . $iterator->current() . PHP_EOL; } // $iterator->current = "d"; $iterator->next(); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/34PRW
function name:  (null)
number of ops:  13
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
   44    12      > RETURN                                                   1

Function traverserecursivearray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 3
Branch analysis from position: 31
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 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 3
Branch analysis from position: 31
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 3
Branch analysis from position: 31
Branch analysis from position: 3
filename:       /in/34PRW
function name:  traverseRecursiveArray
number of ops:  32
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                                                      ->28
   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                                                      ->26
   36    12    >   INIT_METHOD_CALL                                         !0, 'offsetSet'
         13        CHECK_FUNC_ARG                                           
         14        FETCH_OBJ_FUNC_ARG                               $5      !0, 'key'
         15        SEND_FUNC_ARG                                            $5
         16        SEND_VAL_EX                                              'd'
         17        DO_FCALL                                      0          
   37    18        INIT_METHOD_CALL                                         !0, 'key'
         19        DO_FCALL                                      0  $7      
         20        CONCAT                                           ~8      $7, '+%3D%3E+'
         21        INIT_METHOD_CALL                                         !0, 'current'
         22        DO_FCALL                                      0  $9      
         23        CONCAT                                           ~10     ~8, $9
         24        CONCAT                                           ~11     ~10, '%0A'
         25        ECHO                                                     ~11
   42    26    >   INIT_METHOD_CALL                                         !0, 'next'
         27        DO_FCALL                                      0          
   32    28    >   INIT_METHOD_CALL                                         !0, 'valid'
         29        DO_FCALL                                      0  $13     
         30      > JMPNZ                                                    $13, ->3
   44    31    > > RETURN                                                   null

End of function traverserecursivearray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.29 ms | 1400 KiB | 15 Q