<?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 (int $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.4.0 - 5.4.17
- Parse error: syntax error, unexpected '$i' (T_VARIABLE), expecting ';' in /in/P9T8Y on line 11
Process exited with code 255. - Output for 5.3.0 - 5.3.27
- Parse error: syntax error, unexpected T_VARIABLE, expecting ';' in /in/P9T8Y on line 11
Process exited with code 255.
preferences:
177.97 ms | 1395 KiB | 53 Q