note 73440 modified in function.nl2br by thiago
| From: | thiago@php.net | Date: | Wed, 29 Oct 2008 16:04:31 +0000 |
| Subject: | note 73440 modified in function.nl2br by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145936@lists.php.net to get a copy of this message | ||
to replace all linebreaks to <br />
the best solution (IMO) is:
<?php
function nl2br2($string) {
$string = str_replace(array("\r\n", "\r", "\n"), "<br
/>", $string);
return $string;
}
?>
because each OS have different ASCII chars for linebreak:
windows = \r\n
unix = \n
mac = \r
works perfect for me
--was--
to replace all linebreaks to <br />
the best solution (IMO) is:
function nl2br2($string) {
$string = str_replace(array("\r\n", "\r", "\n"), "<br
/>", $string);
return $string;
}
because each OS have different ASCII chars for linebreak:
windows = \r\n
unix = \n
mac = \r
works perfect for me
http://php.net/manual/en/function.nl2br.php