3v4l.org

run code in 300+ PHP versions simultaneously
<?php $births = [1997, 1997, 1997, 1998, 1999]; $deaths = [1998, 1999]; $years = []; foreach ($births as $year) { if (!isset($years[$year])) $years[$year] = 0; $years[$year]++; } foreach ($deaths as $year) { if (!isset($years[$year])) $years[$year] = 0; $years[$year]--; } ksort($years); $acc = 0; $maxYear = null; $maxYearValue = null; foreach ($years as $year => $value) { $acc = $acc + $value; if ($acc > $maxYearValue) { $maxYear = $year; $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:
59.18 ms | 401 KiB | 8 Q