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_merge(...$array) 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 = 7, Position 2 = 20
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/6rcJh
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $result, !2 = $n, !3 = $q
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   49     1        ASSIGN                                                   !1, <array>
   51     2        INIT_FCALL                                               'array_merge'
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_ICALL                                         $6      
          6      > FE_RESET_R                                       $7      $6, ->20
          7    > > FE_FETCH_R                                               $7, $8, ->20
   53     8    >   FETCH_LIST_R                                     $9      $8, 'Product_Name'
          9        ASSIGN                                                   !2, $9
         10        FETCH_LIST_R                                     $11     $8, 'Product_Qty'
         11        ASSIGN                                                   !3, $11
         12        FREE                                                     $8
   55    13        FETCH_DIM_IS                                     ~14     !1, !2
         14        COALESCE                                         ~15     ~14
         15        QM_ASSIGN                                        ~15     0
         16        ADD                                              ~16     ~15, !3
         17        ASSIGN_DIM                                               !1, !2
         18        OP_DATA                                                  ~16
   51    19      > JMP                                                      ->7
         20    >   FE_FREE                                                  $7
   57    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:
138.42 ms | 1001 KiB | 15 Q