note 95582 deleted from function.nl2br by danbrown
| From: | danbrown@php.net | Date: | Mon, 11 Jan 2010 14:56:53 +0000 |
| Subject: | note 95582 deleted from function.nl2br by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164857@lists.php.net to get a copy of this message | ||
Note Submitter: chovy
----
# update to nacho's function (add's optional \s* inbetween break tags and also adds two
newlines inbetween closing/opening p tags).
function br2p($string) { return preg_replace('#<p>[\n\r\s]*?</p>#m',
'', '<p>'.preg_replace('#(<br\s*?/?>\s*){2,}#m',
"</p>\n\n<p>", $string).'</p>');
}