note 56967 added to function.nl2br
| From: | info at antonioceccatelli dot it | Date: | Tue, 20 Sep 2005 14:44:27 +0000 |
| Subject: | note 56967 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95481@lists.php.net to get a copy of this message | ||
I wrote this two functions that are very usefull with mysql BLOB type.
function br2nl4sql($string)
{
// Replace Cr & Lf with a "<br />"
$string = str_replace("\r\n", '<br />', $string);
return $string;
}
function br2nl4html($string)
{
// Replace "<br />" with CR&LF
$string = str_replace("<br />","\n", $string);
return $string;
}
usage:
when you read a field from mysql use this:
$note = br2nl4html(stripslashes($row['note'])));
when you want to save form data to mysql, use this:
$note = br2nl4sql(addslashes($_POST[array_form][note]));
----
Manual Page -- http://www.php.net/manual/en/function.nl2br.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56967
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56967&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56967&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56967&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56967&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56967&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+56967&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56967&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56967&report=yes
Search -- http://master.php.net/manage/user-notes.php