You can use preg_split to split the string on a set of digits, using the PREG_SPLIT_DELIM_CAPTURE option to also capture the digits into the output array:
$string = "abc12345xyz";
$array = preg_split('/(\d+)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
print_r($array);
Output:
Array
(
[0] => abc
[1] => 12345
[2] => xyz
)
Demo on 3v4l.org
Update
Based on the alterations to the question, it seems this regex might be more useful to split on:
\s*(\d+(?::\d+)?)\s*
as it also allows the "numeric" part to look like a time e.g. 6:30. You can use it like this:
$strings = array("abc12345xyz", "pick up at 6:30 pm", "pickup 6 pm", "pickup 6pm");
foreach ($strings as $string) {
$array = preg_split('/\s*(\d+(?::\d+)?)\s*/', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
print_r($array);
}
Output:
Array
(
[0] => abc
[1] => 12345
[2] => xyz
)
Array
(
[0] => pick up at
[1] => 6:30
[2] => pm
)
Array
(
[0] => pickup
[1] => 6
[2] => pm
)
Array
(
[0] => pickup
[1] => 6
[2] => pm
)
Demo on 3v4l.org
abc12345xyzis nothing like splittingpick up at 6:30 pm, especially not if you want to include thepmwith the time part...