3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! $year = array(2011, 2011, 2011, 2012, 2012, 2013, 2013, 2013); $profit = array(23.42, 253.23, 54.5, 433.23, 53.2, 11.4, 45.5, 532.1); $sums = array(); for ($i = 0; $i < count($year); $i++) { if (isset($sums[$year[$i]])) { $sums[$year[$i]] += $profit[$i]; } else { $sums[$year[$i]] = $profit[$i]; } } print_r($sums);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [2011] => 331.15 [2012] => 486.43 [2013] => 589 )

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