3v4l.org

run code in 300+ PHP versions simultaneously
<?php $d = array ( array ( 'a1' => true, 'b1' => 'abc' , 'c1' => 'def' ), array ( 'a2' => true, 'b2' => 'fgh', 'c2' => 'ijk' , 'd2' => 'lmn' , 'e2' => 'opq' )); function flatten(array $array) { $result = array(); if (is_array($array)) { foreach ($array as $k => $v) { if (is_array($v)) { $result = array_merge($result, flatten($v)); } else { $result[$k] = $v; } } } return $result; } $dd = flatten($d); echo "<pre>"; print_r($dd); echo "</pre>"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jtUoq
function name:  (null)
number of ops:  11
compiled vars:  !0 = $d, !1 = $dd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   27     1        INIT_FCALL                                               'flatten'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   28     5        ECHO                                                     '%3Cpre%3E'
   29     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   30     9        ECHO                                                     '%3C%2Fpre%3E'
   31    10      > RETURN                                                   1

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

End of function flatten

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.31 ms | 1403 KiB | 18 Q