note 62858 deleted from function.nl2br by mazzanet
| From: | mazzanet@php.net | Date: | Sat, 11 Mar 2006 06:39:08 +0000 |
| Subject: | note 62858 deleted from function.nl2br by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-105261@lists.php.net to get a copy of this message | ||
Note Submitter: chayden at chayden dot com
----
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"); ?>