3v4l.org

run code in 500+ PHP versions simultaneously
<?php $in = [ [ 'saledate' => '2016-02-01', 'name' => 'John Doe', 'markup' => 561 ], [ 'saledate' => '2016-02-01', 'name' => 'John Doe', 'markup' => 681 ], [ 'saledate' => '2016-02-02', 'name' => 'John Doe', 'markup' => 379 ], [ 'saledate' => '2016-02-01', 'name' => 'Jane Doe', 'markup' => 205 ], [ 'saledate' => '2016-02-02', 'name' => 'Jane Doe', 'markup' => 900 ], [ 'saledate' => '2016-02-02', 'name' => 'Jane Doe', 'markup' => 787 ], [ 'saledate' => '2016-02-03', 'name' => 'Jane Doe', 'markup' => 211 ] ]; $result = []; foreach ($in as ['saledate' => $s, 'name' => $n, 'markup' => $m]) { if (!isset($ref[$n])) { $ref[$n] = ['name' => $n, $s => $m]; $result[] = &$ref[$n]; } else { $ref[$n][$s] = ($ref[$n][$s] ?? 0) +$m; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 32
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 23
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/1lI7q
function name:  (null)
number of ops:  37
compiled vars:  !0 = $in, !1 = $result, !2 = $s, !3 = $n, !4 = $m, !5 = $ref
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   41     1        ASSIGN                                                       !1, <array>
   42     2      > FE_RESET_R                                           $8      !0, ->32
          3    > > FE_FETCH_R                                                   $8, $9, ->32
          4    >   FETCH_LIST_R                                         $10     $9, 'saledate'
          5        ASSIGN                                                       !2, $10
          6        FETCH_LIST_R                                         $12     $9, 'name'
          7        ASSIGN                                                       !3, $12
          8        FETCH_LIST_R                                         $14     $9, 'markup'
          9        ASSIGN                                                       !4, $14
         10        FREE                                                         $9
   43    11        ISSET_ISEMPTY_DIM_OBJ                             0  ~16     !5, !3
         12        BOOL_NOT                                             ~17     ~16
         13      > JMPZ                                                         ~17, ->23
   44    14    >   INIT_ARRAY                                           ~19     !3, 'name'
         15        ADD_ARRAY_ELEMENT                                    ~19     !4, !2
         16        ASSIGN_DIM                                                   !5, !3
         17        OP_DATA                                                      ~19
   45    18        FETCH_DIM_W                                          $21     !5, !3
         19        MAKE_REF                                             $22     $21
         20        FETCH_DIM_W                                          $20     !1
         21        ASSIGN_REF                                                   $20, $22
   43    22      > JMP                                                          ->31
   47    23    >   FETCH_DIM_IS                                         ~26     !5, !3
         24        FETCH_DIM_IS                                         ~27     ~26, !2
         25        COALESCE                                             ~28     ~27
         26        QM_ASSIGN                                            ~28     0
         27        ADD                                                  ~29     ~28, !4
         28        FETCH_DIM_W                                          $24     !5, !3
         29        ASSIGN_DIM                                                   $24, !2
         30        OP_DATA                                                      ~29
   42    31    > > JMP                                                          ->3
         32    >   FE_FREE                                                      $8
   50    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:
147.36 ms | 1799 KiB | 14 Q