3v4l.org

run code in 300+ PHP versions simultaneously
<?php $in = array(); for($i = 1; $i <=5; $i++) { $in['category_id'] = ['sss','ssss'] ; } $res = array();// Array where we will write result $t = &$res; // Link to first level foreach ($in as $key =>$k) { // Walk through source array if (empty($t[$key])) { // Check if current level has required key $t[$key] = []; // If does not, create empty array there $t = &$t[$key]; // 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 = 20
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
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/qDkWI
function name:  (null)
number of ops:  26
compiled vars:  !0 = $in, !1 = $i, !2 = $res, !3 = $t, !4 = $k, !5 = $key
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, 'category_id'
          4        OP_DATA                                                  <array>
    4     5        PRE_INC                                                  !1
          6    >   IS_SMALLER_OR_EQUAL                                      !1, 5
          7      > JMPNZ                                                    ~10, ->3
    8     8    >   ASSIGN                                                   !2, <array>
    9     9        ASSIGN_REF                                               !3, !2
   10    10      > FE_RESET_R                                       $13     !0, ->20
         11    > > FE_FETCH_R                                       ~14     $13, !4, ->20
         12    >   ASSIGN                                                   !5, ~14
   11    13        ISSET_ISEMPTY_DIM_OBJ                         1          !3, !5
         14      > JMPZ                                                     ~16, ->19
   12    15    >   ASSIGN_DIM                                               !3, !5
         16        OP_DATA                                                  <array>
   13    17        FETCH_DIM_W                                      $18     !3, !5
         18        ASSIGN_REF                                               !3, $18
   10    19    > > JMP                                                      ->11
         20    >   FE_FREE                                                  $13
   16    21        UNSET_CV                                                 !3
   17    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.28 ms | 1396 KiB | 15 Q