I am trying to split the string and place in an array using regular expression.
The string may change every time
What I need to do is if the string match with T: then i need to get 4774 4848
If the string matches both T: and M:, then I need my result as
array(
[0] => 4774 4848,
[1]=>0448 888 899
)
This is my code,
if (preg_match("/[T:|M:|Mob:|Phone:]\W(.*)[\W:]/mi", "T: 4774 4848 M: 0448 888 899", $matches))
print_r($matches);
Here my output is
Array
(
[0] => T: 4774 4848 M: 0448 888
[1] => 4774 4848 M: 0448 888
)
How can I split [1] => 4774 4848 M: 0448 888
as
[1] => 4774 4848,
[2]=>0448 888 899
Please help me in getting this. Thanks in advance!