3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => [ 0 => [ "Product_Name" => "Apple Pie - 8", "Product_Qty" => 1, "Product_Cat" => "Pies" ], 1 => [ "Product_Name" => "Apple Pie - 8", "Product_Qty" => 1, "Product_Cat" => "Pies" ] ], 1 => [ 0 => [ "Product_Name" => "Pecan Pie - 8", "Product_Qty" => 1, "Product_Cat" => "Pies" ] ], 2 => [ 0 => [ "Product_Name" => "Strawberry Pie - 8", "Product_Qty" => 1, "Product_Cat" => "Pies" ], 1 => [ "Product_Name" => "Pecan Pie - 8", "Product_Qty" => 1, "Product_Cat" => "Pies" ] ], 3 => [ 0 => [ "Product_Name" => "Lemon Pie - 8", "Product_Qty" => 1, "Product_Cat" => "Pies" ], 1 => [ "Product_Name" => "Pecan Pie - 8", "Product_Qty" => 1, "Product_Cat" => "Pies" ] ] ]; $result = []; foreach ($array as $set) { foreach ($set as ['Product_Name' => $n, 'Product_Qty' => $q]) { $result[$n] = ($result[$n] ?? 0) + $q; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/HHfT5
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $result, !2 = $set, !3 = $n, !4 = $q
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   49     1        ASSIGN                                                   !1, <array>
   50     2      > FE_RESET_R                                       $7      !0, ->20
          3    > > FE_FETCH_R                                               $7, !2, ->20
   51     4    > > FE_RESET_R                                       $8      !2, ->18
          5    > > FE_FETCH_R                                               $8, $9, ->18
          6    >   FETCH_LIST_R                                     $10     $9, 'Product_Name'
          7        ASSIGN                                                   !3, $10
          8        FETCH_LIST_R                                     $12     $9, 'Product_Qty'
          9        ASSIGN                                                   !4, $12
         10        FREE                                                     $9
   52    11        FETCH_DIM_IS                                     ~15     !1, !3
         12        COALESCE                                         ~16     ~15
         13        QM_ASSIGN                                        ~16     0
         14        ADD                                              ~17     ~16, !4
         15        ASSIGN_DIM                                               !1, !3
         16        OP_DATA                                                  ~17
   51    17      > JMP                                                      ->5
         18    >   FE_FREE                                                  $8
   50    19      > JMP                                                      ->3
         20    >   FE_FREE                                                  $7
   55    21        INIT_FCALL                                               'var_export'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.82 ms | 1004 KiB | 15 Q