3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ ['brand' => 'ABC', 'model' => 'xyz', 'size' => 13], ['brand' => 'QWE', 'model' => 'poi', 'size' => 23], ['brand' => 'ABC', 'model' => 'xyz', 'size' => 18], ['brand' => 'QWE', 'model' => 'poi', 'size' => 23], ['brand' => 'ABC', 'model' => 'xyz', 'size' => 18], ]; $result = []; foreach (array_unique($array, SORT_REGULAR) as $row) { $compositeKey = $row['brand'] . '_' . $row['model']; if (!isset($result[$compositeKey])) { $result[$compositeKey] = $row; } else { $result[$compositeKey]['size'] = array_merge((array)$result[$compositeKey]['size'], [$row['size']]); } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 32
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 32
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/PABDD
function name:  (null)
number of ops:  37
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $compositeKey
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   11     1        ASSIGN                                                       !1, <array>
   12     2        INIT_FCALL                                                   'array_unique'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     0
          5        DO_ICALL                                             $6      
          6      > FE_RESET_R                                           $7      $6, ->32
          7    > > FE_FETCH_R                                                   $7, !2, ->32
   13     8    >   FETCH_DIM_R                                          ~8      !2, 'brand'
          9        CONCAT                                               ~9      ~8, '_'
         10        FETCH_DIM_R                                          ~10     !2, 'model'
         11        CONCAT                                               ~11     ~9, ~10
         12        ASSIGN                                                       !3, ~11
   14    13        ISSET_ISEMPTY_DIM_OBJ                             0  ~13     !1, !3
         14        BOOL_NOT                                             ~14     ~13
         15      > JMPZ                                                         ~14, ->19
   15    16    >   ASSIGN_DIM                                                   !1, !3
         17        OP_DATA                                                      !2
   14    18      > JMP                                                          ->31
   17    19    >   INIT_FCALL                                                   'array_merge'
         20        FETCH_DIM_R                                          ~18     !1, !3
         21        FETCH_DIM_R                                          ~19     ~18, 'size'
         22        CAST                                              7  ~20     ~19
         23        SEND_VAL                                                     ~20
         24        FETCH_DIM_R                                          ~21     !2, 'size'
         25        INIT_ARRAY                                           ~22     ~21
         26        SEND_VAL                                                     ~22
         27        DO_ICALL                                             $23     
         28        FETCH_DIM_W                                          $16     !1, !3
         29        ASSIGN_DIM                                                   $16, 'size'
         30        OP_DATA                                                      $23
   12    31    > > JMP                                                          ->7
         32    >   FE_FREE                                                      $7
   20    33        INIT_FCALL                                                   'var_export'
         34        SEND_VAR                                                     !1
         35        DO_ICALL                                                     
         36      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.3 ms | 2046 KiB | 16 Q