note 70692 added to function.nl2br
| From: | http://www dot havarnielsen dot com at osu1 dot php dot net | Date: | Tue, 24 Oct 2006 05:35:22 +0000 |
| Subject: | note 70692 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119055@lists.php.net to get a copy of this message | ||
// nl2br doesn't REPLACE the newline characters with a <br> tag. It just adds a
<br> tag in front of it.
// This function does REPLACE CRLF and newlines with a <br> tag.
function my_nl2br($str)
{
$retvar = str_replace("\n\r", '<br />', $str);
$retvar = str_replace("\n", '<br />', $str);
return $retvar;
}
// And a function to go the oppisite way.
function br2nl($str)
{
return preg_replace('!<br.*>!iU', "\n", $str);
}
----
Server IP: 83.137.200.2
Probable Submitter: 80.202.243.156
----
Manual Page -- http://www.php.net/manual/en/function.nl2br.php
Edit -- https://master.php.net/note/edit/70692
Del: integrated -- https://master.php.net/note/delete/70692/integrated
Del: useless -- https://master.php.net/note/delete/70692/useless
Del: bad code -- https://master.php.net/note/delete/70692/bad+code
Del: spam -- https://master.php.net/note/delete/70692/spam
Del: non-english -- https://master.php.net/note/delete/70692/non-english
Del: in docs -- https://master.php.net/note/delete/70692/in+docs
Del: other reasons-- https://master.php.net/note/delete/70692
Reject -- https://master.php.net/note/reject/70692
Search -- https://master.php.net/manage/user-notes.php