note 43874 added to function.nl2br
| From: | CJ at rn2 dot php dot net | Date: | Wed, 07 Jul 2004 00:26:39 +0000 |
| Subject: | note 43874 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72803@lists.php.net to get a copy of this message | ||
To remove the whitespace at the end of lines, as well as change all different types of newlines to
\n:
$input = ereg_replace(" *\r\n| *\n| *\r)", "\n", $input);
------------
THEN:
To limit the number of newlines in a user's input, you can do this (modify for your situation):
#Reduces >2 newlines down to 2 newlines (Allows for "paragraphs"):
$input = ereg_replace("\n\n+", "\n\n", $input);
------------
THEN:
Don't forget to format the spaces that can mess with your system!
#Gets rid of extra spaces... do whatever suits your needs:
$input = ereg_replace("( +)", ' ', $input);
... and so on...
----
Manual Page -- http://www.php.net/manual/en/function.nl2br.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43874
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43874&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43874&report=yes
Search -- http://master.php.net/manage/user-notes.php