RE: [PHP] Reg ex help-Removing extra blank spaces before HTML output

From: Date: Thu, 06 Dec 2001 08:07:40 +0000
Subject: RE: [PHP] Reg ex help-Removing extra blank spaces before HTML output
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-76838@lists.php.net to get a copy of this message
At 02:43 PM 12/5/01 -0500, Jack Dempsey wrote: >$t = preg_replace('/\s+/',' ',$text); One more thing: How do I replace with newline instead of a space? I read through the manuals but couldn't grasp how to do this. \n didn't cut it. And, more advanced - The above replaces any groups of 2 or more blanks (newlines, spaces, tabs) with a single blank. Is there an easy way to replace them with EITHER a space or a newline, depending on whether any newlines were present in the input? I.e. bbbbbbbbbbbbbb would be replaced with b, but bbbbbnbbbbbnbbbb would be replaced with n. Right now the issue is that I'm sometimes getting results that have no line breaks for a really long time, and I know there are reasons to try to avoid individual lines of HTML longer than 200 characters. Thanks! - Ken kenzo@free-music.com

« previous php.general (#76838) next »