3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'MONDAY' => [ 'REFRIGERATOR' => [3, 9, 7], 'WASHINGMACHINE' => [2, 4, 2, 8] ], 'TUESDAY' => [ 'REFRIGERATOR' => [5, 3, 8], 'OVEN' => [4, 1, 4] ], 'WEDNESDAY' => [ 'TV' => [6, 9], 'REFRIGERATOR' => [2, 3, 5, 2] ], 'THURSDAY' => [ 'TV' => [5, 3, 3, 2], 'FAN' => [4, 9, 8, 5] ], 'FRIDAY' => [ 'WASHINGMACHINE' => [8, 5], 'OVEN' => [3, 9, 7] ] ]; $result = []; foreach ($array as $set) { foreach ($set as $k => $values) { $result[$k] = ($result[$k] ?? 0) + array_sum($values); } } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'REFRIGERATOR' => 47, 'WASHINGMACHINE' => 29, 'OVEN' => 28, 'TV' => 28, 'FAN' => 26, )

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