3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ [ "purchase_amount" => 5000.00, "listing_price" => 5000.00, "home_warranty_cost" => 10.00, "emd" => 100.00, "fee" => 10.00 ], [ "purchase_amount" => 0.00, "listing_price" => 0.00, "home_warranty_cost" => 10.00, "emd" => 100.00, "fee" => 10.00 ], [ "purchase_amount" => 15000.00, "listing_price" => 15000.00, "home_warranty_cost" => 10.00, "emd" => 100.00, "fee" => 10.00 ] ]; $sums = array_reduce($data, function ($carry, $item) { foreach ($item as $key => $value) { $carry[$key] = array_key_exists($key, $carry) ? $carry[$key] + $item[$key] : 0; } return $carry; }, []); print_r($sums);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [purchase_amount] => 15000 [listing_price] => 15000 [home_warranty_cost] => 20 [emd] => 200 [fee] => 20 )

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:
119.56 ms | 405 KiB | 5 Q