3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar = array ( 'Services' => array( array ( '9' => '0', '10' => '0', '11' => '0', '12' => '0', '13' => '0', '14' => '0', '15' => '600' ), ), 'Financial' => array( Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 500 ), Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 200 ), Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 300 ), ), 'DFD' => array( Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 1000, ), Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 100 ) ) ); $finalArray = []; foreach($ar as $key=>$val){ $keyIndexes = array_keys($val[0]); foreach($keyIndexes as $keyIndex){ $finalArray[$key][$keyIndex] = array_sum(array_column($val,$keyIndex)); } } print_r($finalArray);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [Services] => Array ( [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] => 600 ) [Financial] => Array ( [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] => 1000 ) [DFD] => Array ( [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] => 1100 ) )

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:
28.86 ms | 407 KiB | 5 Q