3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array=array( 0 => array( 11 => 18.000, 14 => 25.100, 15 => 5.000, 16 => 8.000, 19 => 21.600 ), 1 => array( 11 => 9.100, 12 => 2.700, 14 => 2.300, 15 => 18.800, 16 => 9.500, 17 => 6.900, 19 => 9.400 ), 2 => array( 14 => 5.700 ), 3 => array( 17 => 2.800, 20 => 6.000 ), 4 => array( 24 => 5.000, 25 => 6.000, 26 => 2.7 ), 5 => array( 16 => 2.200 ), 6 => array( 14 => 13.000, 15 => 2.000, 16 => 4.300, 19 => 6.000 ), 7 => array( 32 => 5.000, 36 => 18.500 ) ); $result=[]; foreach($array as $subarray){ $subarray=array_diff_key($subarray,$result); // deny iteration of previously summed subarray keys foreach($subarray as $k=>$v){ $result[$k]=array_sum(array_column($array,$k)); // sum the whole array's column } } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 11 => 27.1, 14 => 46.1, 15 => 25.8, 16 => 24.0, 19 => 37.0, 12 => 2.7, 17 => 9.7, 20 => 6.0, 24 => 5.0, 25 => 6.0, 26 => 2.7, 32 => 5.0, 36 => 18.5, )

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:
26.39 ms | 401 KiB | 8 Q