note 62858 added to function.nl2br
| From: | chayden at chayden dot com | Date: | Sat, 11 Mar 2006 00:56:19 +0000 |
| Subject: | note 62858 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105253@lists.php.net to get a copy of this message | ||
Update to my original post, a moment of genius; instead of adding a closing "</p>"
in your call to function, simply add it to the function ...
<?php
/* FORMATS LINE BREAKS WITH PROPER HTML TAGS */
function format_html($content)
{
$content = "<p>" . str_replace("\r\n", "<br/>",
$content) . "";
$content = "" . str_replace("<br/><br/>",
"</p><p>", $content) . "";
return "" . str_replace("<br/><li>", "<li>",
$content) . "";
echo("$contect</p>");
}
?>
So, instead of calling the function as originally recommended:
<?php echo format_html("$content</p>"); ?>
You can now call the function without the closing "</p>":
<?php echo format_html("$content"); ?>
----
Server IP: 64.71.164.2
Probable Submitter: 69.9.253.78
----
X-Spam-Status: No, hits=4.0 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_20_30,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.nl2br.php
Edit -- http://master.php.net/note/edit/62858
Del: integrated -- http://master.php.net/note/delete/62858/integrated
Del: useless -- http://master.php.net/note/delete/62858/useless
Del: bad code -- http://master.php.net/note/delete/62858/bad+code
Del: spam -- http://master.php.net/note/delete/62858/spam
Del: non-english -- http://master.php.net/note/delete/62858/non-english
Del: in docs -- http://master.php.net/note/delete/62858/in+docs
Del: other reasons-- http://master.php.net/note/delete/62858
Reject -- http://master.php.net/note/reject/62858
Search -- http://master.php.net/manage/user-notes.php