3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = ['a_a' => '2', 'a_b' => '333', 'c_c' => '123']; function flattenToMultiDimensional(array $array, $delimiter = '.') { $result = []; foreach ($array as $notations => $value) { // extract keys $keys = explode($delimiter, $notations); // reverse keys for assignments $keys = array_reverse($keys); // set initial value $lastVal = $value; foreach ($keys as $key) { // wrap value with key over each iteration $lastVal = [ $key => $lastVal ]; } // merge result $result = array_merge_recursive($result, $lastVal); } return $result; } var_export(flattenToMultiDimensional($array, '_'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N1vmF
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   30     1        INIT_FCALL                                                   'var_export'
          2        INIT_FCALL                                                   'flattentomultidimensional'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     '_'
          5        DO_FCALL                                          0  $2      
          6        SEND_VAR                                                     $2
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function flattentomultidimensional:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 28
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 21
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/N1vmF
function name:  flattenToMultiDimensional
number of ops:  31
compiled vars:  !0 = $array, !1 = $delimiter, !2 = $result, !3 = $value, !4 = $notations, !5 = $keys, !6 = $lastVal, !7 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      '.'
    7     2        ASSIGN                                                       !2, <array>
    8     3      > FE_RESET_R                                           $9      !0, ->28
          4    > > FE_FETCH_R                                           ~10     $9, !3, ->28
          5    >   ASSIGN                                                       !4, ~10
   10     6        INIT_FCALL                                                   'explode'
          7        SEND_VAR                                                     !1
          8        SEND_VAR                                                     !4
          9        DO_ICALL                                             $12     
         10        ASSIGN                                                       !5, $12
   12    11        INIT_FCALL                                                   'array_reverse'
         12        SEND_VAR                                                     !5
         13        DO_ICALL                                             $14     
         14        ASSIGN                                                       !5, $14
   15    15        ASSIGN                                                       !6, !3
   16    16      > FE_RESET_R                                           $17     !5, ->21
         17    > > FE_FETCH_R                                                   $17, !7, ->21
   19    18    >   INIT_ARRAY                                           ~18     !6, !7
   18    19        ASSIGN                                                       !6, ~18
   16    20      > JMP                                                          ->17
         21    >   FE_FREE                                                      $17
   24    22        INIT_FCALL                                                   'array_merge_recursive'
         23        SEND_VAR                                                     !2
         24        SEND_VAR                                                     !6
         25        DO_ICALL                                             $20     
         26        ASSIGN                                                       !2, $20
    8    27      > JMP                                                          ->4
         28    >   FE_FREE                                                      $9
   27    29      > RETURN                                                       !2
   28    30*     > RETURN                                                       null

End of function flattentomultidimensional

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.3 ms | 1885 KiB | 18 Q