Page 1 of 1

Stripping whitespace

Posted: Thu Jul 13, 2006 8:45 pm
by HiddenS3crets
Is there any quick way to replace x amount of spaces with only one?

ex. (assume '-' is one space)
Before: This is----a---test------string
After: This is a test string

Posted: Thu Jul 13, 2006 8:47 pm
by Weirdan
sure:

Code: Select all

$str = preg_replace('\s+', ' ', $str);