note 37228 deleted from function.nl2br by tomsommer
| From: | tomsommer@php.net | Date: | Sun, 27 Jun 2004 19:07:58 +0000 |
| Subject: | note 37228 deleted from function.nl2br by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71950@lists.php.net to get a copy of this message | ||
Note Submitter: Junkie [Matt]
----
With the complaints of nl2br, here is one of the simplest ways to fix it:
<?
function nl2br($str) {
$str = preg_replace('/\n/i', '<br />', $str);
return $str;
}
function br2nl($str) {
$str = preg_replace('/<br( )?(\/)?>/i', '\n', $str);
return $str;
}
// And a fun little xhtml function to use
function br2xhtml($str) {
$str = preg_replace('/<br( )?(\/)?>/i', '<br />', $str);
return $str;
}
?>