You can use preg_split instead. Then you can use images that match the position between the word a letter:
$result = preg_split('/(?<=\d)(?=[az])|(?<=[az])(?=\d)/i', $input);
Note that \w also matches numbers (and underscores) in addition to letters.
An alternative (using the match function) is to use preg_match_all and match only numbers or letters for each match:
preg_match_all('/\d+|[az]+/i', $input, $result);
Instead of captures, you will get one match for each of the desired elements in the resulting array. But in the end, you need an array, so you don't care where they came from.
source share