3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: i in /in/O2O7f on line 11 Notice: Undefined variable: i in /in/O2O7f on line 12 Notice: Undefined index: in /in/O2O7f on line 12 Notice: Undefined variable: i in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 11 Array ( [] => [2010] => 60 [2011] => 150 [2012] => 50 [2013] => 40 )
Output for hhvm-3.12.0
Notice: Undefined variable: i in /in/O2O7f on line 17 Notice: Undefined variable: i in /in/O2O7f on line 11 Notice: Undefined index: in /in/O2O7f on line 12 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 11 Array ( [] => [2010] => 60 [2011] => 150 [2012] => 50 [2013] => 40 )
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.1.0 - 5.2.17
Notice: Undefined variable: i in /in/O2O7f on line 11 Notice: Undefined variable: i in /in/O2O7f on line 12 Notice: Undefined index: in /in/O2O7f on line 12 Notice: Undefined variable: i in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 11 Array ( [] => [2010] => 60 [2011] => 150 [2012] => 50 [2013] => 40 )
Output for 5.0.4 - 5.0.5
Notice: Undefined variable: i in /in/O2O7f on line 11 Notice: Undefined variable: i in /in/O2O7f on line 11 Notice: Undefined variable: i in /in/O2O7f on line 12 Notice: Undefined index: in /in/O2O7f on line 12 Notice: Undefined variable: i in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 11 Array ( [] => [2010] => 60 [2011] => 150 [2012] => 50 [2013] => 40 )
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: i in /in/O2O7f on line 11 Notice: Undefined variable: i in /in/O2O7f on line 11 Notice: Undefined variable: i in /in/O2O7f on line 12 Notice: Undefined index: in /in/O2O7f on line 12 Notice: Undefined variable: i in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 15 Notice: Undefined index: in /in/O2O7f on line 15 Notice: Undefined variable: i in /in/O2O7f on line 11 Array ( [] => [2010] => 60 [2011] => 150 [2012] => 50 [2013] => 40 )