3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ "one" => "one", "two" => "two", "group1" => [ "three" => "three", "four" => "four", "group2" => [ "five" => "five", ], ], "group3" => [ "six" => "six", ] ]; function mergeRecursive(array $array, $result = []) { foreach($array as $k => $v) { if(!is_array($v)) yield $v; else yield "$k," . mergeRecursive($v, $result); } } foreach(mergeRecursive($arr) as $v) echo $v . "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/NMGdN
function name:  (null)
number of ops:  11
compiled vars:  !0 = $arr, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   34     1        INIT_FCALL                                               'mergerecursive'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4      > FE_RESET_R                                       $4      $3, ->9
          5    > > FE_FETCH_R                                               $4, !1, ->9
   35     6    >   CONCAT                                           ~5      !1, '%0A'
          7        ECHO                                                     ~5
   34     8      > JMP                                                      ->5
          9    >   FE_FREE                                                  $4
   35    10      > RETURN                                                   1

Function mergerecursive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 20
filename:       /in/NMGdN
function name:  mergeRecursive
number of ops:  22
compiled vars:  !0 = $array, !1 = $result, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2        GENERATOR_CREATE                                         
   23     3      > FE_RESET_R                                       $4      !0, ->20
          4    > > FE_FETCH_R                                       ~5      $4, !2, ->20
          5    >   ASSIGN                                                   !3, ~5
   24     6        TYPE_CHECK                                  128  ~7      !2
          7        BOOL_NOT                                         ~8      ~7
          8      > JMPZ                                                     ~8, ->11
   25     9    >   YIELD                                                    !2
         10      > JMP                                                      ->19
   27    11    >   NOP                                                      
         12        FAST_CONCAT                                      ~10     !3, '%2C'
         13        INIT_FCALL_BY_NAME                                       'mergeRecursive'
         14        SEND_VAR_EX                                              !2
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $11     
         17        CONCAT                                           ~12     ~10, $11
         18        YIELD                                                    ~12
   23    19    > > JMP                                                      ->4
         20    >   FE_FREE                                                  $4
   31    21      > GENERATOR_RETURN                                         

End of function mergerecursive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.73 ms | 1403 KiB | 14 Q