3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getAvailableSubscriptionEndYears() { $currentYear = intval(date_create()->format('Y')); $availableYears = array($currentYear => $currentYear); for($i=1;$i<10;$i++) { var_dump('x'); $nextYear = $currentYear+$i; $availableYears[$nextYear] = $nextYear; } return $availableYears; } var_dump(getAvailableSubscriptionEndYears()); ?>
based on GLGmY
Output for 5.3.18 - 5.4.45, 7.0.20 - 7.2.0
string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" array(10) { [2015]=> int(2015) [2016]=> int(2016) [2017]=> int(2017) [2018]=> int(2018) [2019]=> int(2019) [2020]=> int(2020) [2021]=> int(2021) [2022]=> int(2022) [2023]=> int(2023) [2024]=> int(2024) }
Output for 5.5.24 - 7.0.6
string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" string(1) "x" array(10) { [2016]=> int(2016) [2017]=> int(2017) [2018]=> int(2018) [2019]=> int(2019) [2020]=> int(2020) [2021]=> int(2021) [2022]=> int(2022) [2023]=> int(2023) [2024]=> int(2024) [2025]=> int(2025) }