I have string like:
$message="AB 1234 Hello, how are you?
I want to get like this:
$message[0] = AB
$message[1] = 1234
$message[2] = Hello, how are you?
Please don’t suggest substr function because length of first two words may vary but they will have spaces in between.
Any other suggestion?
Use
explode()with a limit, egIf you need more flexibility around the word delimiter, you can do something similar with
preg_split()Demo – http://codepad.org/1gLJEFIa