3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arrayFlat($arr){ $out = ''; foreach($arr as $key => $value){ if(!is_array($value)){ $out .= $value.','; }else{ $out .= $key.','; $out .= arrayFlat($value); } } return trim($out,','); } $aNonFlat = array( 1, 2, array( 3, 4, 5, array( 6, 7 ), 8, 9, ), 10, 11 ); $result = explode(',',arrayFlat($aNonFlat)); echo '<pre>'; print_r($result); echo '</pre>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U3bfp
function name:  (null)
number of ops:  15
compiled vars:  !0 = $aNonFlat, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   35     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2C'
          3        INIT_FCALL                                               'arrayflat'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !1, $4
   36     9        ECHO                                                     '%3Cpre%3E'
   37    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
   38    13        ECHO                                                     '%3C%2Fpre%3E'
         14      > RETURN                                                   1

Function arrayflat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/U3bfp
function name:  arrayFlat
number of ops:  25
compiled vars:  !0 = $arr, !1 = $out, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, ''
    4     2      > FE_RESET_R                                       $5      !0, ->18
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->18
          4    >   ASSIGN                                                   !3, ~6
    6     5        TYPE_CHECK                                  128  ~8      !2
          6        BOOL_NOT                                         ~9      ~8
          7      > JMPZ                                                     ~9, ->11
    7     8    >   CONCAT                                           ~10     !2, '%2C'
          9        ASSIGN_OP                                     8          !1, ~10
         10      > JMP                                                      ->17
    9    11    >   CONCAT                                           ~12     !3, '%2C'
         12        ASSIGN_OP                                     8          !1, ~12
   10    13        INIT_FCALL_BY_NAME                                       'arrayFlat'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0  $14     
         16        ASSIGN_OP                                     8          !1, $14
    4    17    > > JMP                                                      ->3
         18    >   FE_FREE                                                  $5
   14    19        INIT_FCALL                                               'trim'
         20        SEND_VAR                                                 !1
         21        SEND_VAL                                                 '%2C'
         22        DO_ICALL                                         $16     
         23      > RETURN                                                   $16
   15    24*     > RETURN                                                   null

End of function arrayflat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.57 ms | 1407 KiB | 20 Q