3v4l.org

run code in 300+ PHP versions simultaneously
<?php function recursiveFind(array $array, $needle) { $iterator = new RecursiveArrayIterator($array); $recursive = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::SELF_FIRST ); $return = []; foreach ($recursive as $key => $value) { if ($key === $needle) { $return[] = $value; } } return $return; } $array = [ 'foo' => 'one', 'bar' => [ 'boo' => 'two', 'foo' => 'three', 'loo' => [ 'foo' => 'four', ], ], 'goo' => [ 'foo' => 'five', ] ]; var_export(recursiveFind($array, 'foo'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SVcq7
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   31     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'recursivefind'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'foo'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function recursivefind:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/SVcq7
function name:  recursiveFind
number of ops:  23
compiled vars:  !0 = $array, !1 = $needle, !2 = $iterator, !3 = $recursive, !4 = $return, !5 = $value, !6 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        NEW                                              $7      'RecursiveArrayIterator'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $7
    5     6        NEW                                              $10     'RecursiveIteratorIterator'
    6     7        SEND_VAR_EX                                              !2
    7     8        SEND_VAL_EX                                              1
          9        DO_FCALL                                      0          
    5    10        ASSIGN                                                   !3, $10
    9    11        ASSIGN                                                   !4, <array>
   10    12      > FE_RESET_R                                       $14     !3, ->20
         13    > > FE_FETCH_R                                       ~15     $14, !5, ->20
         14    >   ASSIGN                                                   !6, ~15
   11    15        IS_IDENTICAL                                             !6, !1
         16      > JMPZ                                                     ~17, ->19
   12    17    >   ASSIGN_DIM                                               !4
         18        OP_DATA                                                  !5
   10    19    > > JMP                                                      ->13
         20    >   FE_FREE                                                  $14
   15    21      > RETURN                                                   !4
   16    22*     > RETURN                                                   null

End of function recursivefind

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.54 ms | 1403 KiB | 16 Q