note 51524 added to function.nl2br
| From: | jochem at vuilnisbak dot com | Date: | Sat, 02 Apr 2005 16:43:52 +0000 |
| Subject: | note 51524 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87349@lists.php.net to get a copy of this message | ||
For people trying br2nl, but getting stuck at double newlines (or at least more then needed), try
this:
<?php
function br2nl($coffee) {
$coffee = str_replace("\r\n", "\n", $coffee); // make from windows-returns,
*nix-returns
$coffee = str_replace("<br />\n", "\n", $coffee); // to retrieve it
return $coffee;
}
?>
The first thing \r\n is replacing linebreaks made on Windows systems. I believe *nix systems only
place \n (not sure about it).
Have fun.
Jochem
----
Manual Page -- http://www.php.net/manual/en/function.nl2br.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51524
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51524&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51524&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51524&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51524&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51524&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51524&report=yes
Search -- http://master.php.net/manage/user-notes.php