3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = array( 'test' => array( 'derp' => array( 'example' => true, 'test' => 'derp'), 'herpa' => 'derpa', 'perpa' => 'hurradur')); function flatten($array, $current_path='test') { $result = array(); foreach($array as $key => $val) { $path = $current_path . '.' . $key; if (is_array($val)) { $result[$path] = $val; $result = array_merge($result, flatten($val, $path)); } else { $result[$path] = $val; } } return $result; } var_dump(flatten($config));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Pnl13
function name:  (null)
number of ops:  8
compiled vars:  !0 = $config
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'flatten'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

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

End of function flatten

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.39 ms | 1394 KiB | 18 Q