3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['level' => 1, 'data' => [['level' => 2],['level' => 3, 'data' => [['level' => 6]]]]], ['level' => 4], ['level' => 9, 'data' => [['level' => 8]]], ]; function flat($data, &$list = []) { foreach ($data as $key => $value) { if (isset($value['data']) && is_array($value['data'])) { $tmp = $value['data']; unset($value['data']); flat($tmp, $list); } $list[] = $value; } return $list; } print_r(flat($arr));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Rtn5f
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'flat'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function flat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 10
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/Rtn5f
function name:  flat
number of ops:  24
compiled vars:  !0 = $data, !1 = $list, !2 = $value, !3 = $key, !4 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   11     2      > FE_RESET_R                                       $5      !0, ->21
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->21
          4    >   ASSIGN                                                   !3, ~6
   12     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !2, 'data'
          6      > JMPZ_EX                                          ~8      ~8, ->10
          7    >   FETCH_DIM_R                                      ~9      !2, 'data'
          8        TYPE_CHECK                                  128  ~10     ~9
          9        BOOL                                             ~8      ~10
         10    > > JMPZ                                                     ~8, ->18
   13    11    >   FETCH_DIM_R                                      ~11     !2, 'data'
         12        ASSIGN                                                   !4, ~11
   14    13        UNSET_DIM                                                !2, 'data'
   15    14        INIT_FCALL_BY_NAME                                       'flat'
         15        SEND_VAR_EX                                              !4
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
   17    18    >   ASSIGN_DIM                                               !1
         19        OP_DATA                                                  !2
   11    20      > JMP                                                      ->3
         21    >   FE_FREE                                                  $5
   19    22      > RETURN                                                   !1
   20    23*     > RETURN                                                   null

End of function flat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
123.83 ms | 1013 KiB | 15 Q