note 21855 added to function.nl2br
| From: | jhfh at hetnet dot nl | Date: | Wed, 29 May 2002 13:53:21 +0000 |
| Subject: | note 21855 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31149@lists.php.net to get a copy of this message | ||
for the br2nl problem, use:
(in php)
function br2nl($string) {
$string = str_replace('<br />|<br/>|<br>', '\r\n', $string);
return $string;
}
(in javascript, header of the document)
<SCRIPT language="JavaScript">
MyString="<?php print br2nl($YourTextFromDatabase); ?>";
</SCRIPT>
and, finally, in the body tag:
onLoad="document.formName.NameofTextarea.value=MyString"
now, you have the text in your textarea, just the way people entered it!
maybe there's a (little) error in the script, but it works fine for me!
(please send comments to the e-mailaddress above)
--
http://www.php.net/manual/en/function.nl2br.php
http://master.php.net/manage/user-notes.php?action=edit+21855
http://master.php.net/manage/user-notes.php?action=delete+21855
http://master.php.net/manage/user-notes.php?action=reject+21855