3v4l.org

run code in 300+ PHP versions simultaneously
<?php $in = array(); for($i = 1; $i <=5; $i++) { $in[] = i; } $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 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
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 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/eg4cn
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                                                      ->8
   6     3    >   FETCH_CONSTANT                                   ~8      'i'
         4        ASSIGN_DIM                                               !0
         5        OP_DATA                                                  ~8
   4     6        POST_INC                                         ~9      !1
         7        FREE                                                     ~9
         8    >   CAST                                          0  ~10     !1, 5
         9      > JMPNZ                                                    ~10, ->3
   8    10    >   ASSIGN                                                   !2, <array>
   9    11        ASSIGN_REF                                               !3, !2
  10    12      > FE_RESET_R                                       $13     !0, ->21
        13    > > FE_FETCH_R                                               $13, !4, ->21
  11    14    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~14     !3, !4
        15      > JMPZ                                                     ~14, ->20
  12    16    >   ASSIGN_DIM                                               !3, !4
        17        OP_DATA                                                  <array>
  13    18        FETCH_DIM_W                                      $16     !3, !4
        19        ASSIGN_REF                                               !3, $16
  10    20    > > JMP                                                      ->13
        21    >   FE_FREE                                                  $13
  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:
47.17 ms | 462 KiB | 7 Q