3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_flatten_iterator (array $array) { foreach ($array as $value) { if (is_array($value)) { yield from array_flatten_iterator($value); } else { yield $value; } } } function array_flatten (array $array) { return iterator_to_array(array_flatten_iterator($array), false); } $array = [ 1, 2, [ 3, 4, 5, [ 6, 7 ], 8, 9, ], 10, 11, ]; var_dump(array_flatten($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RU30W
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   35     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_flatten'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function array_flatten_iterator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 14
filename:       /in/RU30W
function name:  array_flatten_iterator
number of ops:  16
compiled vars:  !0 = $array, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2      > FE_RESET_R                                       $2      !0, ->14
          3    > > FE_FETCH_R                                               $2, !1, ->14
    5     4    >   TYPE_CHECK                                  128          !1
          5      > JMPZ                                                     ~3, ->12
    6     6    >   INIT_FCALL_BY_NAME                                       'array_flatten_iterator'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $4      
          9        YIELD_FROM                                       ~5      $4
         10        FREE                                                     ~5
    5    11      > JMP                                                      ->13
    8    12    >   YIELD                                                    !1
    4    13    > > JMP                                                      ->3
         14    >   FE_FREE                                                  $2
   11    15      > GENERATOR_RETURN                                         

End of function array_flatten_iterator

Function array_flatten:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RU30W
function name:  array_flatten
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'iterator_to_array'
          2        INIT_FCALL                                               'array_flatten_iterator'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        SEND_VAL                                                 <false>
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
   15     9*     > RETURN                                                   null

End of function array_flatten

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.45 ms | 1468 KiB | 17 Q