3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_flatten($array = null) { $result = array(); if (!is_array($array)) { $array = func_get_args(); } foreach ($array as $key => $value) { if (is_array($value)) { $result = array_merge($result, array_flatten($value)); } else { $result = array_merge($result, array($key => $value)); } } return $result; } $myarray = array('a', ['bla' => 0], 'b',[0,1], [0=>7], array(array(array('x'), 'y', 'z')), array(array('p'))); $res = array_flatten($myarray); var_dump( $res); $string_res = array_flatten( 'cramp' ); var_dump( $string_res );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6fHhP
function name:  (null)
number of ops:  16
compiled vars:  !0 = $myarray, !1 = $res, !2 = $string_res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'array_flatten'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   23     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   25     8        INIT_FCALL                                               'array_flatten'
          9        SEND_VAL                                                 'cramp'
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !2, $7
   26    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function array_flatten:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 28
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 28
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 7
filename:       /in/6fHhP
function name:  array_flatten
number of ops:  31
compiled vars:  !0 = $array, !1 = $result, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      null
    4     1        ASSIGN                                                   !1, <array>
    6     2        TYPE_CHECK                                  128  ~5      !0
          3        BOOL_NOT                                         ~6      ~5
          4      > JMPZ                                                     ~6, ->7
    7     5    >   FUNC_GET_ARGS                                    ~7      
          6        ASSIGN                                                   !0, ~7
   10     7    > > FE_RESET_R                                       $9      !0, ->28
          8    > > FE_FETCH_R                                       ~10     $9, !2, ->28
          9    >   ASSIGN                                                   !3, ~10
   11    10        TYPE_CHECK                                  128          !2
         11      > JMPZ                                                     ~12, ->21
   12    12    >   INIT_FCALL                                               'array_merge'
         13        SEND_VAR                                                 !1
         14        INIT_FCALL_BY_NAME                                       'array_flatten'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0  $13     
         17        SEND_VAR                                                 $13
         18        DO_ICALL                                         $14     
         19        ASSIGN                                                   !1, $14
         20      > JMP                                                      ->27
   14    21    >   INIT_FCALL                                               'array_merge'
         22        SEND_VAR                                                 !1
         23        INIT_ARRAY                                       ~16     !2, !3
         24        SEND_VAL                                                 ~16
         25        DO_ICALL                                         $17     
         26        ASSIGN                                                   !1, $17
   10    27    > > JMP                                                      ->8
         28    >   FE_FREE                                                  $9
   18    29      > RETURN                                                   !1
   19    30*     > RETURN                                                   null

End of function array_flatten

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.7 ms | 1407 KiB | 19 Q