3v4l.org

run code in 300+ PHP versions simultaneously
<?php // user input of years $ar = [1944, 1674, 3021]; // find max year $maxCentury = max(...$ar); // get max century $roundedCentury = round($maxCentury, -3); foreach($ar as $year) { foreach(range(0, $roundedCentury, 1000) as $century) { if($century <= $year) { echo "<li> $century <ul>" . $year . "</ul> </li>"; } } }

preferences:
54.79 ms | 402 KiB | 5 Q