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] ]; $result = []; foreach ($array 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(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/t0f4T
function name:  (null)
number of ops:  36
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>
    9     1        ASSIGN                                                       !1, <array>
   10     2      > FE_RESET_R                                           $6      !0, ->28
          3    > > FE_FETCH_R                                                   $6, !2, ->28
   11     4    >   FETCH_DIM_R                                          ~7      !2, 'brand'
          5        CONCAT                                               ~8      ~7, '_'
          6        FETCH_DIM_R                                          ~9      !2, 'model'
          7        CONCAT                                               ~10     ~8, ~9
          8        ASSIGN                                                       !3, ~10
   12     9        ISSET_ISEMPTY_DIM_OBJ                             0  ~12     !1, !3
         10        BOOL_NOT                                             ~13     ~12
         11      > JMPZ                                                         ~13, ->15
   13    12    >   ASSIGN_DIM                                                   !1, !3
         13        OP_DATA                                                      !2
   12    14      > JMP                                                          ->27
   15    15    >   INIT_FCALL                                                   'array_merge'
         16        FETCH_DIM_R                                          ~17     !1, !3
         17        FETCH_DIM_R                                          ~18     ~17, 'size'
         18        CAST                                              7  ~19     ~18
         19        SEND_VAL                                                     ~19
         20        FETCH_DIM_R                                          ~20     !2, 'size'
         21        INIT_ARRAY                                           ~21     ~20
         22        SEND_VAL                                                     ~21
         23        DO_ICALL                                             $22     
         24        FETCH_DIM_W                                          $15     !1, !3
         25        ASSIGN_DIM                                                   $15, 'size'
         26        OP_DATA                                                      $22
   10    27    > > JMP                                                          ->3
         28    >   FE_FREE                                                      $6
   18    29        INIT_FCALL                                                   'var_export'
         30        INIT_FCALL                                                   'array_values'
         31        SEND_VAR                                                     !1
         32        DO_ICALL                                             $23     
         33        SEND_VAR                                                     $23
         34        DO_ICALL                                                     
         35      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.77 ms | 2033 KiB | 16 Q