Forum Moderators: coopster
$content = nl2br($content); $print "<p>$content</p>";
Produces this:
<p>line 1<br /> line 2<br /> <br /> line 3</p>
Can it be done with somethind so the following occurs:
<p>line 1</p> <p>line 2</p> <p>line 3</p>
Cheers
$text = 'Some text..<br /> with line breaks..'; $text = nl2br($text); $text = str_replace( '<br />', '</p><p>', $text); echo '<p>'.$text.'</p>';
?>
Should do it. :)
$content = str_replace("\n","</p>\n<p>",$content);$print "<p>$content</p>";
That should do the trick properly. Don't feel offended ;)
--hakre
function nl2p($content) { $content = explode("\n",$content); foreach($content as $key => $line) { $lines[$key] = "<p>".$line."</p>"; } $content = implode("\n",$lines); return $content; }
should do the trick
$content=sprintf('<p>%s</p>',preg_replace("/\r*\n/","</p>\n<p>",$content));
(Untested code, as usual)