RE: [PHP] remove whitespace
| From: | WILSON, Nick | Date: | Wed, 08 Nov 2000 02:54:16 +0000 |
| Subject: | RE: [PHP] remove whitespace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-24245@lists.php.net to get a copy of this message | ||
I don't know of any function, but this should do the trick
$string = preg_replace("/[\w]+/i", " ", $string);
> -----Original Message-----
> From: David Otton [mailto:djo@jawbone.freeserve.co.uk]
> Sent: Wednesday, 8 November 2000 10:47
> To: php-general@lists.php.net
> Subject: [PHP] remove whitespace
>
>
> Hi - I suspect there is a function to do this, but I can't find it.
>
> I want to remove extraneous whitespace-like characters from a string,
> so
>
> "this is\n a \t string with \nweird spacing"
>
> becomes
>
> "this is a string with weird spacing"
>
> best I can come up with is to use str_replace() to turn all the
> unwanted chars into plain " "s, then explode() and implode() the
> string.
>
> Is there a faster way?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
>