One way to do it is:
$NewString = ereg_replace('[[:space:]]+', ' ', $String);
There are also ways to do it with preg functions that are slightly
more efficient; see the pcre docs. And, the standard (AFAIK)
reference book for regular expressions is O'Reilly's 'Mastering
Regular Expressions'; a worthwhile purchase.
-steve
At 2:06 AM -0500 12/5/01, Ken wrote:
>I want to remove all superfluous blank spaces before I sent my HTML
>output, to make the output smaller.
>
>So I'd like to take $input, replace any number of blank space or
>newlines that are consecutive and replace them with a single blank.
>
>I.e. I will list a blank space as b and a newline as n:
>
>If input is: bbbbbTEXTHEREbbbnnnbnMOREbEVENMORE
>Then output should be: bTEXTHEREbMOREbEVENMORE
>
>I imagine this would be handled by a simple regular expression call,
>but I'm no pro with them yet.
>
>Any help?
>
>Thanks,
>Ken
>[EMAIL PROTECTED]
>
--
+------------------------------------------------------------------------+
| Steve Edberg [EMAIL PROTECTED] |
| University of California, Davis (530)754-9127 |
| Programming/Database/SysAdmin http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| "Restriction of free thought and free speech is the most dangerous of |
| all subversions. It is the one un-American act that could most easily |
| defeat us." |
| - Supreme Court Justice (1939-1975) William O. Douglas |
+------------------------------------------------------------------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]