3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['quantity' => 5, 'dd' => '01-Nov-2012'], ['quantity' => 10, 'dd' => '01-Nov-2012'], ['quantity' => 3, 'dd' => '02-Nov-2012'], ['quantity' => 4, 'dd' => '03-Nov-2012'], ['quantity' => 15, 'dd' => '03-Nov-2012'], ]; $result = []; foreach ($array as $row) { if (!isset($ref[$row['dd']])) { $ref[$row['dd']] = $row; $result[] = &$ref[$row['dd']]; } else { $ref[$row['dd']]['quantity'] += $row['quantity']; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/FsSnj
function name:  (null)
number of ops:  28
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $6      !0, ->23
          3    > > FE_FETCH_R                                               $6, !2, ->23
   13     4    >   FETCH_DIM_R                                      ~7      !2, 'dd'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !3, ~7
          6        BOOL_NOT                                         ~9      ~8
          7      > JMPZ                                                     ~9, ->17
   14     8    >   FETCH_DIM_R                                      ~10     !2, 'dd'
          9        ASSIGN_DIM                                               !3, ~10
         10        OP_DATA                                                  !2
   15    11        FETCH_DIM_R                                      ~13     !2, 'dd'
         12        FETCH_DIM_W                                      $14     !3, ~13
         13        MAKE_REF                                         $15     $14
         14        FETCH_DIM_W                                      $12     !1
         15        ASSIGN_REF                                               $12, $15
   13    16      > JMP                                                      ->22
   17    17    >   FETCH_DIM_R                                      ~17     !2, 'dd'
         18        FETCH_DIM_R                                      ~20     !2, 'quantity'
         19        FETCH_DIM_RW                                     $18     !3, ~17
         20        ASSIGN_DIM_OP                +=               1          $18, 'quantity'
         21        OP_DATA                                                  ~20
   12    22    > > JMP                                                      ->3
         23    >   FE_FREE                                                  $6
   20    24        INIT_FCALL                                               'var_export'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.11 ms | 1003 KiB | 14 Q