I am wondering what other approaches you would take to do some simple string splitting in PHP. I am receiving a response from a SMS gateway where two of the interesting values are the code used and the users text message.

The code could be something like: `Freetrip` (lowercase, uppercase, mixed case)

The user message should in the best case scenario be e.g. like: `Freetrip 12345` ($code "space" XXXXX).

Each X should be a digit between 1 and 5. Any other value/character should return an error. So the regex would be simplified as: chars=5 where each digit >=1 and <=5.

What I need to store at the end would be each of the 5 digits values.

My simplest approach would be to lowercase the entire message string and subtract the also lowercased code (plus the space) from the message string. That would leave me with the 5 digits which I would then split into 5 unique variables to store in the DB.

Now the tricky part is that the best case scenario described above may be hard to achieve. Typing a SMS is fiddly and typing errors occur easily. Some errors that may occur are the following:

* Too few or many digits.
* Non-digits characters.
* More characters after the XXXXX combination.
* Probably some other cases.

Any of those should return an individual error message which I can return to the sender.