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; $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
Warning: Undefined variable $i in /in/O2O7f on line 11 Warning: Undefined variable $i in /in/O2O7f on line 12 Warning: Undefined array key "" in /in/O2O7f on line 12 Warning: Undefined variable $i in /in/O2O7f on line 15 Warning: Undefined array key "" in /in/O2O7f on line 15 Warning: Undefined variable $i in /in/O2O7f on line 15 Warning: Undefined array key "" in /in/O2O7f on line 15 Warning: Undefined variable $i in /in/O2O7f on line 11 Array ( [] => [2010] => 60 [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:
41.39 ms | 402 KiB | 8 Q