3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rows = [ ['cat' => 'guest', 'name' => 'name_one', 'y' => '2016', 'q' => '2', 'st' => 1], ['cat' => 'guest', 'name' => 'name_one', 'y' => '2017', 'q' => '3', 'st' => 2], ['cat' => 'guest', 'name' => 'name_two', 'y' => '2017', 'q' => '1', 'st' => 1], ['cat' => 'guest', 'name' => 'name_two', 'y' => '2017', 'q' => '2', 'st' => 2], ]; $data = []; foreach ($rows as $row) { $link = &$data; foreach (['cat', 'name', 'y'] as $field) { if (!isset($link[$row[$field]])) $link[$row[$field]] = []; $link = &$link[$row[$field]]; } $link[$row['q']] = $row['st']; unset($link); } print_r($data);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 25
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/Ml6Yg
function name:  (null)
number of ops:  30
compiled vars:  !0 = $rows, !1 = $data, !2 = $row, !3 = $link, !4 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   11     2      > FE_RESET_R                                       $7      !0, ->25
          3    > > FE_FETCH_R                                               $7, !2, ->25
   12     4    >   ASSIGN_REF                                               !3, !1
   13     5      > FE_RESET_R                                       $9      <array>, ->18
          6    > > FE_FETCH_R                                               $9, !4, ->18
   14     7    >   FETCH_DIM_R                                      ~10     !2, !4
          8        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !3, ~10
          9        BOOL_NOT                                         ~12     ~11
         10      > JMPZ                                                     ~12, ->14
         11    >   FETCH_DIM_R                                      ~13     !2, !4
         12        ASSIGN_DIM                                               !3, ~13
         13        OP_DATA                                                  <array>
   15    14    >   FETCH_DIM_R                                      ~15     !2, !4
         15        FETCH_DIM_W                                      $16     !3, ~15
         16        ASSIGN_REF                                               !3, $16
   13    17      > JMP                                                      ->6
         18    >   FE_FREE                                                  $9
   17    19        FETCH_DIM_R                                      ~18     !2, 'q'
         20        FETCH_DIM_R                                      ~20     !2, 'st'
         21        ASSIGN_DIM                                               !3, ~18
         22        OP_DATA                                                  ~20
   18    23        UNSET_CV                                                 !3
   11    24      > JMP                                                      ->3
         25    >   FE_FREE                                                  $7
   20    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.74 ms | 1388 KiB | 15 Q