I have this id taken from a table:
"B0AL02087"
How do I convert this alphanumeric id to a intergre number representation? I am expecting "B0AL02087" to something like "2011202087".
I found a way of doing this using an alphabet range with a string split, the index of the letter in the alphabet switches out the letters in the key:
$alphabet = range('A', 'Z');
$arr = str_split("B0AL02087");
$arr[0] = array_search($arr[0], $alphabet);
$arr[2] = array_search($arr[2], $alphabet);
$arr[3] = array_search($arr[3], $alphabet);
implode($arr), '0');
But this method only works when you specify the index of $arr which means it doesn't work when the format of the id from the table changes, e.g.
"BBAL02087"
Now we have two letters at the start of a string rather than a letter and an intergre like the first one. I could write a bunch of if statements check if each index contains a number. I just wasn't sure if there is a better way to do this.