3v4l.org

run code in 300+ PHP versions simultaneously
<?php $people = [ [1801, 1887], [1943, 1943], [1949, 2001], [1751, 1803], [1881, 1887], [1956, 1983], [1954, 1983], [1801, 1883], [1956, null], [1944, 1983], [1897, 2015], [1965, 1997], [1941, 1982], [1984, null], ]; $populationPerYear = array_reduce( $people, static function($carry, $current) { [$from, $to] = $current; for($i = $from; $i <= $to; $i++) { if (!isset($carry[$i])) { $carry[$i] = 1; } else { $carry[$i]++; } } return $carry; }, [] ); ksort($populationPerYear); $peak = max($populationPerYear); $peakYears = array_filter( $populationPerYear, static function($population) use ($peak) { return $population === $peak; } ); var_dump($peak, $peakYears);
Output for git.master, git.master_jit, rfc.property-hooks
int(7) array(18) { [1965]=> int(7) [1966]=> int(7) [1967]=> int(7) [1968]=> int(7) [1969]=> int(7) [1970]=> int(7) [1971]=> int(7) [1972]=> int(7) [1973]=> int(7) [1974]=> int(7) [1975]=> int(7) [1976]=> int(7) [1977]=> int(7) [1978]=> int(7) [1979]=> int(7) [1980]=> int(7) [1981]=> int(7) [1982]=> int(7) }

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:
45.79 ms | 402 KiB | 8 Q