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['category_id']) { // 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 = 21
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
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/biZmO
function name:  (null)
number of ops:  27
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, ->21
         11    > > FE_FETCH_R                                               $12, $13, ->21
         12    >   ASSIGN_DIM                                               !4, 'category_id'
         13        OP_DATA                                                  $13
   11    14        ISSET_ISEMPTY_DIM_OBJ                         1          !3, !4
         15      > JMPZ                                                     ~15, ->20
   12    16    >   ASSIGN_DIM                                               !3, !4
         17        OP_DATA                                                  <array>
   13    18        FETCH_DIM_W                                      $17     !3, !4
         19        ASSIGN_REF                                               !3, $17
   10    20    > > JMP                                                      ->11
         21    >   FE_FREE                                                  $12
   16    22        UNSET_CV                                                 !3
   17    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.01 ms | 1396 KiB | 15 Q