3v4l.org

run code in 300+ PHP versions simultaneously
<?php $births = [1997, 1997, 1997, 1998, 1999]; $deaths = [1998, 1999]; $years = []; $min = PHP_INT_MAX; $max = -1; foreach ($births as $year) { if (!isset($years[$year])) $years[$year] = 0; $min = min($min, $year); $max = max($max, $year); $years[$year]++; } foreach ($deaths as $year) { if (!isset($years[$year])) $years[$year] = 0; $min = min($min, $year); $max = max($max, $year); $years[$year]--; } $acc = 0; $maxYear = null; $maxYearValue = null; for ($i = $min; $i <= $max; $i++) { if (!isset($years[$i])) { continue; } $acc += $years[$i]; if ($acc > $maxYearValue) { $maxYear = $i; $maxYearValue = $acc; } } var_dump($maxYear, $maxYearValue);
Output for git.master, git.master_jit, rfc.property-hooks
int(1997) int(3)

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