I have a code in php/mysql that gets ids from the database. The ids are in the form of a letter + a set of 3 digits. For example a123
I would like to be able to split the code to 2 variables $var1 = 'a' and $var2 = '123'
I thought of using php and regular expressions; looked at preg_match. I am not sure on how to get the first letter. I also thought about using explode in php and a limit or str_split like this:
$arr = str_split($str, 1);
but then this will split it into: a 1 2 3 4 and I’ll end up with 4 values instead of 2.
Any suggestions please. (I am open to doing it in javascript as well I can pass it through ajax)
If it’s always 4 characters:
If you really want a regex: