3v4l.org

run code in 300+ PHP versions simultaneously
<?php // First Array $a = [ [ "sales" => [ ["Date" => "2014-04-01", "Units" => 1], ["Date" => "2014-04-02", "Units" => 7] ] ] ]; $b = [ [ "sales" => [ ["Date" => "2014-04-01", "Units" => 3], ["Date" => "2014-04-02", "Units" => 2] ] ] ]; $c = [ [ "sales" => [ ["Date" => "2014-04-01", "Units" => 0], ["Date" => "2014-04-02", "Units" => 5] ] ] ]; $result = []; foreach (array_merge($a[0]['sales'], $b[0]['sales'], $c[0]['sales']) as $row) { if (!isset($ref[$row['Date']])) { $ref[$row['Date']] = $row; $result[] =& $ref[$row['Date']]; } else { $ref[$row['Date']]['Units'] += $row['Units']; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 36
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 36
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/LAd3O
function name:  (null)
number of ops:  41
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $result, !4 = $row, !5 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, <array>
   22     2        ASSIGN                                                   !2, <array>
   31     3        ASSIGN                                                   !3, <array>
   32     4        INIT_FCALL                                               'array_merge'
          5        FETCH_DIM_R                                      ~10     !0, 0
          6        FETCH_DIM_R                                      ~11     ~10, 'sales'
          7        SEND_VAL                                                 ~11
          8        FETCH_DIM_R                                      ~12     !1, 0
          9        FETCH_DIM_R                                      ~13     ~12, 'sales'
         10        SEND_VAL                                                 ~13
         11        FETCH_DIM_R                                      ~14     !2, 0
         12        FETCH_DIM_R                                      ~15     ~14, 'sales'
         13        SEND_VAL                                                 ~15
         14        DO_ICALL                                         $16     
         15      > FE_RESET_R                                       $17     $16, ->36
         16    > > FE_FETCH_R                                               $17, !4, ->36
   33    17    >   FETCH_DIM_R                                      ~18     !4, 'Date'
         18        ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !5, ~18
         19        BOOL_NOT                                         ~20     ~19
         20      > JMPZ                                                     ~20, ->30
   34    21    >   FETCH_DIM_R                                      ~21     !4, 'Date'
         22        ASSIGN_DIM                                               !5, ~21
         23        OP_DATA                                                  !4
   35    24        FETCH_DIM_R                                      ~24     !4, 'Date'
         25        FETCH_DIM_W                                      $25     !5, ~24
         26        MAKE_REF                                         $26     $25
         27        FETCH_DIM_W                                      $23     !3
         28        ASSIGN_REF                                               $23, $26
   33    29      > JMP                                                      ->35
   37    30    >   FETCH_DIM_R                                      ~28     !4, 'Date'
         31        FETCH_DIM_R                                      ~31     !4, 'Units'
         32        FETCH_DIM_RW                                     $29     !5, ~28
         33        ASSIGN_DIM_OP                +=               1          $29, 'Units'
         34        OP_DATA                                                  ~31
   32    35    > > JMP                                                      ->16
         36    >   FE_FREE                                                  $17
   40    37        INIT_FCALL                                               'var_export'
         38        SEND_VAR                                                 !3
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.28 ms | 1006 KiB | 15 Q