3v4l.org

run code in 300+ PHP versions simultaneously
<?php $in = array(); for($i = 1; $i <=5; $i++) { $in[] = ['category_id','title']; } $res = array();// Array where we will write result $t = &$res; // Link to first level foreach ($in as $k) { // Walk through source array if (empty($t[$k])) { // Check if current level has required key $t[$k] = array(); // If does not, create empty array there $t = &$t[$k]; // And link to it now. So each time it is link to deepest level. } } unset($t); // Drop link to last (most deep) level var_dump($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
Branch analysis from position: 3
filename:       /in/0RMuF
function name:  (null)
number of ops:  25
compiled vars:  !0 = $in, !1 = $i, !2 = $res, !3 = $t, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 1
          2      > JMP                                                      ->6
    6     3    >   ASSIGN_DIM                                               !0
          4        OP_DATA                                                  <array>
    4     5        PRE_INC                                                  !1
          6    >   IS_SMALLER_OR_EQUAL                                      !1, 5
          7      > JMPNZ                                                    ~9, ->3
    8     8    >   ASSIGN                                                   !2, <array>
    9     9        ASSIGN_REF                                               !3, !2
   10    10      > FE_RESET_R                                       $12     !0, ->19
         11    > > FE_FETCH_R                                               $12, !4, ->19
   11    12    >   ISSET_ISEMPTY_DIM_OBJ                         1          !3, !4
         13      > JMPZ                                                     ~13, ->18
   12    14    >   ASSIGN_DIM                                               !3, !4
         15        OP_DATA                                                  <array>
   13    16        FETCH_DIM_W                                      $15     !3, !4
         17        ASSIGN_REF                                               !3, $15
   10    18    > > JMP                                                      ->11
         19    >   FE_FREE                                                  $12
   16    20        UNSET_CV                                                 !3
   17    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.58 ms | 1396 KiB | 15 Q