3v4l.org

run code in 300+ PHP versions simultaneously
<?php $consumption = [ '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($consumption as $v) { foreach($v as $v_k => $v_v) { if(isset($result[$v_k])) $result[$v_k] += array_sum($v_v); else $result[$v_k] = array_sum($v_v); } } print_r($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:
67.2 ms | 401 KiB | 8 Q