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($tree)); foreach ($iterator as $key => $value) { if ($key == "selected" && $value) { $selectedValues[] = $iterator["key"]; } } var_dump($selectedValues);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
Branch analysis from position: 15
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/bQ5sK
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $selectedValues, !2 = $iterator, !3 = $tree, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   13     2        NEW                                              $8      'RecursiveIteratorIterator'
          3        NEW                                              $9      'RecursiveArrayIterator'
          4        SEND_VAR_EX                                              !3
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $9
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $8
   14     9      > FE_RESET_R                                       $13     !2, ->20
         10    > > FE_FETCH_R                                       ~14     $13, !4, ->20
         11    >   ASSIGN                                                   !5, ~14
   15    12        IS_EQUAL                                         ~16     !5, 'selected'
         13      > JMPZ_EX                                          ~16     ~16, ->15
         14    >   BOOL                                             ~16     !4
         15    > > JMPZ                                                     ~16, ->19
   16    16    >   FETCH_DIM_R                                      ~18     !2, 'key'
         17        ASSIGN_DIM                                               !1
         18        OP_DATA                                                  ~18
   14    19    > > JMP                                                      ->10
         20    >   FE_FREE                                                  $13
   19    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.97 ms | 1396 KiB | 15 Q