Re: Separating spaces from the rest
| From: | Anguz | Date: | Fri, 30 Apr 2004 23:59:33 +0000 |
| Subject: | Re: Separating spaces from the rest | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185081@lists.php.net to get a copy of this message | ||
Thanks! I was just reading that function in the manual when I got your reply. I tested it but I still have a couple of problems with it.
print_r(preg_split('(\s+)', " word1 word2 word3.", -1, PREG_SPLIT_DELIM_CAPTURE));
I get this:
Array
(
[0] =>
[1] => word1
[2] => word2
[3] => word3.
)
In [0] the spaces aren't there and it's splitting the other spaces too, where I need to only split the leading spaces. How should I write it?
TIA,
Anguz
Kemper, Helmut wrote:
Hi, See preg_explite and use "/(\s+)/" for explode string into array. Tanks, Kemper ------------------------------------------------------------------------ ----------------------------------------------------------------- Helmut Kemper kemper@kemper.com.br Celular (Mobile): 55 81 99268744 On 30/04/2004, at 20:22, Anguz wrote:I have an array with many strings, of which most have spaces or tabs at the beginning, but no fixed number of them. Example:$arr[0] = ' Hello.';How can I separate them into two strings? Like: Array ([0] => Array ( [0] => " " //I added the quotes to notice the space. [1] => Hello. )) TIA! Anguz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php