note 66261 deleted from function.nl2br by googleguy
| From: | googleguy@php.net | Date: | Thu, 13 Jun 2013 11:11:11 +0000 |
| Subject: | note 66261 deleted from function.nl2br by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195183@lists.php.net to get a copy of this message | ||
Note Submitter: godfrank DOMAIN-IS msn TLD-IS com
----
I have modified my function found in the previous post.
It now uses preg_replace() which should technically be faster than ereg_replace(). You can also
specify what you want to replace "\r\n" with. If you use the function with only one
parameter, it will use '<br />' by default.
<?php
function nl2brStrict($text, $replacement = '<br />')
{
return preg_replace("((\r\n)+)", trim($replacement), $text);
}
?>