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) { if ($acc !== 0) { $years[$year] = $value + $acc; } $acc = $acc + $value; if ($acc > $maxYearValue) { $maxYear = $year; $maxYearValue = $acc; } } var_dump($years, $maxYear, $maxYearValue);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [1997]=> int(3) [1998]=> int(3) [1999]=> int(3) } 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:
31.91 ms | 401 KiB | 8 Q