I wish to split a text string into words separated by spaces. I use
$words=explode(" ", $text);
Unfortunately, this method doesn't work well for me, because I want to know how many spaces are in between.
Is there any better way to do that than going through the whole $text, symbol by symbol, using while statement to fill out $spaces ( $spaces=array(); ) with integers (number of spaces, in most cases it is 1) and read text into $words=array() symbol by symbol?
Here is an additional explanation.
$text="Hello_world_____123"; //symbol "_" actually means a space
Needed:
$words=("Hello","world","123");
$spaces=(1,5);