3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convert_uk_reg_year_to_yyyy($year) { // Normalise year to padded with 1 leading zero, if necessary. This ensures that // if the input is int(9) instead of string(2) "09" then it will still work as // expected. $year = str_pad((int)$year, 2, 0, STR_PAD_LEFT); // Make sure input is within valid range if ($year < 0 || $year > 99) { return false; } // Create result return "20" . ($year[0] % 5) . $year[1]; } // given examples var_dump(convert_uk_reg_year_to_yyyy(55)); var_dump(convert_uk_reg_year_to_yyyy(03)); var_dump(convert_uk_reg_year_to_yyyy(62)); // future plates var_dump(convert_uk_reg_year_to_yyyy(17)); // 2017 var_dump(convert_uk_reg_year_to_yyyy(22)); // 2022 var_dump(convert_uk_reg_year_to_yyyy(72)); // 2022 // invalid input var_dump(convert_uk_reg_year_to_yyyy(101)); var_dump(convert_uk_reg_year_to_yyyy(-1)); var_dump(convert_uk_reg_year_to_yyyy(999));
Output for git.master, git.master_jit, rfc.property-hooks
string(4) "2005" string(4) "2003" string(4) "2012" string(4) "2017" string(4) "2022" string(4) "2022" bool(false) bool(false) bool(false)

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.47 ms | 401 KiB | 8 Q