3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ "id" => 96, "shipping_no" => "212755-1", "part_no" => "reterty", "description" => "tyrfyt", "packaging_type" => "PC" ], [ "id" => 96, "shipping_no" => "212755-1", "part_no" => "dftgtryh", "description" => "dfhgfyh", "packaging_type" => "PC" ], [ "id" => 97, "shipping_no" => "212755-2", "part_no" => "ZeoDark", "description" => "s%c%s%c%s", "packaging_type" => "PC" ] ]; $result = []; foreach ($array as $row) { $key = $row['id']; // assign the grouping column's value unset($row['id']); if (!isset($ref[$key])) { $ref[$key] = [$row]; $result[] = &$ref[$key]; } else { $ref[$key][] = $row; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/m6ZXl
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $key, !4 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   27     1        ASSIGN                                                   !1, <array>
   28     2      > FE_RESET_R                                       $7      !0, ->22
          3    > > FE_FETCH_R                                               $7, !2, ->22
   29     4    >   FETCH_DIM_R                                      ~8      !2, 'id'
          5        ASSIGN                                                   !3, ~8
   30     6        UNSET_DIM                                                !2, 'id'
   31     7        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !4, !3
          8        BOOL_NOT                                         ~11     ~10
          9      > JMPZ                                                     ~11, ->18
   32    10    >   INIT_ARRAY                                       ~13     !2
         11        ASSIGN_DIM                                               !4, !3
         12        OP_DATA                                                  ~13
   33    13        FETCH_DIM_W                                      $15     !4, !3
         14        MAKE_REF                                         $16     $15
         15        FETCH_DIM_W                                      $14     !1
         16        ASSIGN_REF                                               $14, $16
         17      > JMP                                                      ->21
   35    18    >   FETCH_DIM_W                                      $18     !4, !3
         19        ASSIGN_DIM                                               $18
         20        OP_DATA                                                  !2
   28    21    > > JMP                                                      ->3
         22    >   FE_FREE                                                  $7
   38    23        INIT_FCALL                                               'var_export'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.73 ms | 1401 KiB | 15 Q