note 37228 modified in function.nl2br by didou
| From: | didou@php.net | Date: | Thu, 08 Jan 2004 08:52:55 +0000 |
| Subject: | note 37228 modified in function.nl2br by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-63137@lists.php.net to get a copy of this message | ||
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;
}
?>
--was--
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);
}
function br2nl($str) {
$str = preg_replace('/<br( )?(\/)?>/i', '\n', $str);
}
// And a fun little xhtml function to use
function br2xhtml($str) {
$str = preg_replace('/<br( )?(\/)?>/i', '<br />', $str);
}
?>
http://www.php.net/manual/en/function.nl2br.php