3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 'key1' => 'Label 1', 'key2' => 'Label 2', 'key3' => 'Label 3' ]; $result = array(); $r = &$result; foreach ($arr as $k => $v) { $r[$k] = array($k => $v); $r = &$r[$k]; } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/M94NV
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arr, !1 = $result, !2 = $r, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
    9     2        ASSIGN_REF                                               !2, !1
   10     3      > FE_RESET_R                                       $8      !0, ->12
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->12
          5    >   ASSIGN                                                   !4, ~9
   11     6        INIT_ARRAY                                       ~12     !3, !4
          7        ASSIGN_DIM                                               !2, !4
          8        OP_DATA                                                  ~12
   12     9        FETCH_DIM_W                                      $13     !2, !4
         10        ASSIGN_REF                                               !2, $13
   10    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $8
   14    13        INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.82 ms | 1010 KiB | 14 Q