3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function flatten_array($array, $flat = array()) { foreach($array as $k=>$v){ $k = strval($k); if(!is_array($v)){ $i = 0; while(true){ $i++; $key = $k."-".strval($i); if(!isset($flat[$key])) break; } $flat[$key] = $v; }else{ $flat = flatten_array($v, $flat); } } return $flat; } // this line generates a 10x10 multi-d array $a = array_fill(0, 10, array_fill(0, 10, 0)); $flat_array = flatten_array($a); var_dump($flat_array);
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /in/6QVj0
function name:  (null)
number of ops:  20
compiled vars:  !0 = $a, !1 = $flat_array
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  22     1        INIT_FCALL                                               'array_fill'
         2        SEND_VAL                                                 0
         3        SEND_VAL                                                 10
         4        INIT_FCALL                                               'array_fill'
         5        SEND_VAL                                                 0
         6        SEND_VAL                                                 10
         7        SEND_VAL                                                 0
         8        DO_ICALL                                         $2      
         9        SEND_VAR                                                 $2
        10        DO_ICALL                                         $3      
        11        ASSIGN                                                   !0, $3
  24    12        INIT_FCALL                                               'flatten_array'
        13        SEND_VAR                                                 !0
        14        DO_FCALL                                      0  $5      
        15        ASSIGN                                                   !1, $5
  25    16        INIT_FCALL                                               'var_dump'
        17        SEND_VAR                                                 !1
        18        DO_ICALL                                                 
        19      > RETURN                                                   1

Function flatten_array:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 77) Position 1 = 3, Position 2 = 32
Branch analysis from position: 3
Jump found. (Code = 78) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
Jump found. (Code = 43) Position 1 = 10, Position 2 = 26
Branch analysis from position: 10
Jump found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Jump found. (Code = 44) Position 1 = 23, Position 2 = 12
Branch analysis from position: 23
Jump found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Jump found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
Jump found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
Jump found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 22
Branch analysis from position: 26
Jump found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 32
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/6QVj0
function name:  flatten_array
number of ops:  35
compiled vars:  !0 = $array, !1 = $flat, !2 = $v, !3 = $k, !4 = $i, !5 = $key
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
         1        RECV_INIT                                        !1      <array>
   4     2      > FE_RESET_R                                       $6      !0, ->32
         3    > > FE_FETCH_R                                       ~7      $6, !2, ->32
         4    >   ASSIGN                                                   !3, ~7
   5     5        CAST                                          6  ~9      !3
         6        ASSIGN                                                   !3, ~9
   6     7        TYPE_CHECK                                    7  ~11     !2
         8        BOOL_NOT                                         ~12     ~11
         9      > JMPZ                                                     ~12, ->26
   7    10    >   ASSIGN                                                   !4, 0
   8    11      > JMP                                                      ->22
   9    12    >   POST_INC                                         ~14     !4
        13        FREE                                                     ~14
  10    14        CONCAT                                           ~15     !3, '-'
        15        CAST                                          6  ~16     !4
        16        CONCAT                                           ~17     ~15, ~16
        17        ASSIGN                                                   !5, ~17
  11    18        ISSET_ISEMPTY_DIM_OBJ                       33554432  ~19     !1, !5
        19        BOOL_NOT                                         ~20     ~19
        20      > JMPZ                                                     ~20, ->22
        21    > > JMP                                                      ->23
   8    22    > > JMPNZ                                                    <true>, ->12
  13    23    >   ASSIGN_DIM                                               !1, !5
        24        OP_DATA                                                  !2
        25      > JMP                                                      ->31
  15    26    >   INIT_FCALL_BY_NAME                                       'flatten_array'
        27        SEND_VAR_EX                                              !2
        28        SEND_VAR_EX                                              !1
        29        DO_FCALL                                      0  $22     
        30        ASSIGN                                                   !1, $22
        31    > > JMP                                                      ->3
        32    >   FE_FREE                                                  $6
  18    33      > RETURN                                                   !1
  19    34*     > RETURN                                                   null

End of function flatten_array

Generated using Vulcan Logic Dumper, using php 7.3.0