3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = [ "Friday" => ["Breakfast" => 32, "Lunch" => 45], "Sunday" => ["Lunch" => 12] ]; $arr2 = [ "Sunday" => ["Breakfast" => 7, "Lunch" => 3], "Monday" => ["Breakfast" => 12] ]; $arr3 = [ "Monday" => ["Breakfast" => 31] ]; $result = []; foreach (array_merge_recursive($arr1, $arr2, $arr3) as $day => $meals) { foreach ($meals as $meal => $counts) { $result[$day][$meal] = array_sum((array)$counts); } } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'Friday' => array ( 'Breakfast' => 32, 'Lunch' => 45, ), 'Sunday' => array ( 'Lunch' => 15, 'Breakfast' => 7, ), 'Monday' => array ( 'Breakfast' => 43, ), )

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:
116.04 ms | 406 KiB | 5 Q