3v4l.org

run code in 300+ PHP versions simultaneously
<?php function flatten_array($array) { foreach ($array as $i => $items) { foreach ($items as $key => $value) { $ar[$key.'-'.($i+1)] = $value; } } return $ar; } // this line generates a 10x10 multi-d array $a = array_fill(0, 10, array_fill(0, 10, array_fill(0, 5, 1))); $flat_array = flatten_array($a); var_dump($flat_array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C1JWk
function name:  (null)
number of ops:  24
compiled vars:  !0 = $a, !1 = $flat_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'array_fill'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 10
          3        INIT_FCALL                                               'array_fill'
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 10
          6        INIT_FCALL                                               'array_fill'
          7        SEND_VAL                                                 0
          8        SEND_VAL                                                 5
          9        SEND_VAL                                                 1
         10        DO_ICALL                                         $2      
         11        SEND_VAR                                                 $2
         12        DO_ICALL                                         $3      
         13        SEND_VAR                                                 $3
         14        DO_ICALL                                         $4      
         15        ASSIGN                                                   !0, $4
   15    16        INIT_FCALL                                               'flatten_array'
         17        SEND_VAR                                                 !0
         18        DO_FCALL                                      0  $6      
         19        ASSIGN                                                   !1, $6
   16    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function flatten_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 15
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/C1JWk
function name:  flatten_array
number of ops:  18
compiled vars:  !0 = $array, !1 = $items, !2 = $i, !3 = $value, !4 = $key, !5 = $ar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1      > FE_RESET_R                                       $6      !0, ->15
          2    > > FE_FETCH_R                                       ~7      $6, !1, ->15
          3    >   ASSIGN                                                   !2, ~7
    5     4      > FE_RESET_R                                       $9      !1, ->13
          5    > > FE_FETCH_R                                       ~10     $9, !3, ->13
          6    >   ASSIGN                                                   !4, ~10
    6     7        CONCAT                                           ~12     !4, '-'
          8        ADD                                              ~13     !2, 1
          9        CONCAT                                           ~14     ~12, ~13
         10        ASSIGN_DIM                                               !5, ~14
         11        OP_DATA                                                  !3
    5    12      > JMP                                                      ->5
         13    >   FE_FREE                                                  $9
    4    14      > JMP                                                      ->2
         15    >   FE_FREE                                                  $6
    9    16      > RETURN                                                   !5
   10    17*     > RETURN                                                   null

End of function flatten_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.68 ms | 1403 KiB | 18 Q