Working on a way to convert the number part of a UK licence plate to that of the reg year.
The aim is to take e.g 55 / 03 / 62
And output how they should be: 2005 / 2003 / 2012
My initial plan was this:
function convertPlateYearToYYYY($vrmYear) {
$firstDigit = substr($vrmYear, 0, 1);
$secondDigit = substr($vrmYear, 1, 1);
if ($firstDigit == 6) {
$partOne = '1';
} else {
$partOne = '0';
}
$date = "20" . $partOne . $secondDigit;
return $secondDigit;
}
$vrmYear = '05'
echo convertPlateYearToYYYY($vrmYear);
This works fine, but if submitting a value that starts with 0 (like in the example) the substr seems to fail and doesnt return anything. How do I overcome this?