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] ]; var_export( array_values( array_reduce( $array, function ($carry, $row) { $compositeKey = $row['brand'] . '_' . $row['model']; if (!isset($carry[$compositeKey])) { $carry[$compositeKey] = $row; } else { $carry[$compositeKey]['size'] = array_merge( (array)$carry[$compositeKey]['size'], [$row['size']] ); } return $carry; } ) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C5642
function name:  (null)
number of ops:  13
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    9     1        INIT_FCALL                                                   'var_export'
   10     2        INIT_FCALL                                                   'array_values'
   11     3        INIT_FCALL                                                   'array_reduce'
   12     4        SEND_VAR                                                     !0
   13     5        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
   24     6        SEND_VAL                                                     ~2
   11     7        DO_ICALL                                             $3      
   24     8        SEND_VAR                                                     $3
   10     9        DO_ICALL                                             $4      
   24    10        SEND_VAR                                                     $4
    9    11        DO_ICALL                                                     
   27    12      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C5642
function name:  {closure:/in/C5642:13}
number of ops:  27
compiled vars:  !0 = $carry, !1 = $row, !2 = $compositeKey
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   14     2        FETCH_DIM_R                                          ~3      !1, 'brand'
          3        CONCAT                                               ~4      ~3, '_'
          4        FETCH_DIM_R                                          ~5      !1, 'model'
          5        CONCAT                                               ~6      ~4, ~5
          6        ASSIGN                                                       !2, ~6
   15     7        ISSET_ISEMPTY_DIM_OBJ                             0  ~8      !0, !2
          8        BOOL_NOT                                             ~9      ~8
          9      > JMPZ                                                         ~9, ->13
   16    10    >   ASSIGN_DIM                                                   !0, !2
         11        OP_DATA                                                      !1
   15    12      > JMP                                                          ->25
   18    13    >   INIT_FCALL                                                   'array_merge'
   19    14        FETCH_DIM_R                                          ~13     !0, !2
         15        FETCH_DIM_R                                          ~14     ~13, 'size'
         16        CAST                                              7  ~15     ~14
         17        SEND_VAL                                                     ~15
   20    18        FETCH_DIM_R                                          ~16     !1, 'size'
         19        INIT_ARRAY                                           ~17     ~16
         20        SEND_VAL                                                     ~17
   18    21        DO_ICALL                                             $18     
         22        FETCH_DIM_W                                          $11     !0, !2
         23        ASSIGN_DIM                                                   $11, 'size'
   20    24        OP_DATA                                                      $18
   23    25    > > RETURN                                                       !0
   24    26*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.34 ms | 2034 KiB | 17 Q