3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Everything you enter here will be executed by our servers. Try it! 2011 23.42 2011 253.23 2011 54.5 2012 433.23 2012 53.2 2013 11.4 2013 45.5 2013 532.1 $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 5.4.0 - 5.4.17
Parse error: syntax error, unexpected '23.42' (T_DNUMBER) in /in/dF2TT on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_DNUMBER in /in/dF2TT on line 5
Process exited with code 255.