3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! $year = array(2010,2010,2010,2011,2011,2012,2013); $profit = array(100,50,10,80,70,50,40); $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 ( [2010] => 160 [2011] => 150 [2012] => 50 [2013] => 40 )

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