3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( array("title" => 1, "children" => array( array( "selected" => true, "key" => 12345, "children" => array() ) ) ) ); $selectedValues = array(); $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array)); foreach ($iterator as $key => $value) { if ($key == "selected") { $depth = $iterator->getDepth(); $a = $iterator->getSubIterator($depth); var_dump($a); // echo $value . PHP_EOL; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/0Lb44
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array, !1 = $selectedValues, !2 = $iterator, !3 = $value, !4 = $key, !5 = $depth, !6 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   13     2        NEW                                              $9      'RecursiveIteratorIterator'
          3        NEW                                              $10     'RecursiveArrayIterator'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $10
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $9
   14     9      > FE_RESET_R                                       $14     !2, ->25
         10    > > FE_FETCH_R                                       ~15     $14, !3, ->25
         11    >   ASSIGN                                                   !4, ~15
   15    12        IS_EQUAL                                                 !4, 'selected'
         13      > JMPZ                                                     ~17, ->24
   16    14    >   INIT_METHOD_CALL                                         !2, 'getDepth'
         15        DO_FCALL                                      0  $18     
         16        ASSIGN                                                   !5, $18
   17    17        INIT_METHOD_CALL                                         !2, 'getSubIterator'
         18        SEND_VAR_EX                                              !5
         19        DO_FCALL                                      0  $20     
         20        ASSIGN                                                   !6, $20
   18    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !6
         23        DO_ICALL                                                 
   14    24    > > JMP                                                      ->10
         25    >   FE_FREE                                                  $14
   21    26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.58 ms | 1396 KiB | 15 Q