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);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'Apple Pie - 8' => 2, 'Pecan Pie - 8' => 3, 'Strawberry Pie - 8' => 1, 'Lemon Pie - 8' => 1, )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
53.58 ms | 405 KiB | 5 Q