3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.83 ms | 1395 KiB | 15 Q