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])) { $row['size'] = (array)$row['size']; $result[$compositeKey] = $row; } else { $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 = 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 = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/7mT9F
function name:  (null)
number of ops:  33
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, ->25
          3    > > FE_FETCH_R                                                   $6, !2, ->25
   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, ->19
   13    12    >   FETCH_DIM_R                                          ~15     !2, 'size'
         13        CAST                                              7  ~16     ~15
         14        ASSIGN_DIM                                                   !2, 'size'
         15        OP_DATA                                                      ~16
   14    16        ASSIGN_DIM                                                   !1, !3
         17        OP_DATA                                                      !2
   12    18      > JMP                                                          ->24
   16    19    >   FETCH_DIM_R                                          ~21     !2, 'size'
         20        FETCH_DIM_W                                          $18     !1, !3
         21        FETCH_DIM_W                                          $19     $18, 'size'
         22        ASSIGN_DIM                                                   $19
         23        OP_DATA                                                      ~21
   10    24    > > JMP                                                          ->3
         25    >   FE_FREE                                                      $6
   19    26        INIT_FCALL                                                   'var_export'
         27        INIT_FCALL                                                   'array_values'
         28        SEND_VAR                                                     !1
         29        DO_ICALL                                             $22     
         30        SEND_VAR                                                     $22
         31        DO_ICALL                                                     
         32      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.79 ms | 2041 KiB | 15 Q