note 50294 deleted from function.nl2br by googleguy
| From: | googleguy@php.net | Date: | Thu, 13 Jun 2013 11:01:26 +0000 |
| Subject: | note 50294 deleted from function.nl2br by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195149@lists.php.net to get a copy of this message | ||
Note Submitter: asentis at gmail dot com
----
If you want to respect W3C, you can use this function :
<?php
function nl2p($str)
{
return str_replace('<p></p>', '', '<p>' .
preg_replace('#\n|\r#', '</p>$0<p>', $str) .
'</p>');
}
?>
Cya :)