note 62799 added to function.nl2br
| From: | AndersNorrbring at osu1 dot php dot net | Date: | Thu, 09 Mar 2006 21:28:48 +0000 |
| Subject: | note 62799 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105167@lists.php.net to get a copy of this message | ||
Seeing all these suggestions on a br2nl function, I can also see that neither would work with a
sloppy written html line break.. Users can't be trusted to write good code, we know that, and
mixing case isn't too uncommon.
I think this little snippet would do most tricks, both XHTML style and HTML, even mixed case like
<Br> <bR /> and even <br > or <br />.
<?php
function br2nl($text)
{
return preg_replace('/<br\\s*?\/??>/i', '', $text);
}
?>
----
Server IP: 129.16.214.50
Probable Submitter: 81.216.110.47
----
X-Spam-Status: No, hits=4.2 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_40_50,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.nl2br.php
Edit -- http://master.php.net/note/edit/62799
Del: integrated -- http://master.php.net/note/delete/62799/integrated
Del: useless -- http://master.php.net/note/delete/62799/useless
Del: bad code -- http://master.php.net/note/delete/62799/bad+code
Del: spam -- http://master.php.net/note/delete/62799/spam
Del: non-english -- http://master.php.net/note/delete/62799/non-english
Del: in docs -- http://master.php.net/note/delete/62799/in+docs
Del: other reasons-- http://master.php.net/note/delete/62799
Reject -- http://master.php.net/note/reject/62799
Search -- http://master.php.net/manage/user-notes.php