|
Posted by Chris Hope on 07/13/05 12:07
Martin Magnusson wrote:
> I'm trying to "html-ise" some text, where an empty line should be
> interpreted as a paragraph break.
>
> I thought that
> $text = str_replace("\n\n", "</p><p>", $text);
> would work, but that doesn't find anything to replace in my strings,
> and $text = str_replace("\n", "</p><p>", $text);
> gives me too many paragraphs, of course.
>
> As an example of what I want, this message should be divided into
> three paragraphs.
It's possible your text contains a carriage return as well as line
break. In that case, you'd want to do this:
$text = str_replace("\r\n\r\n", "</p><p>", $text);
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Navigation:
[Reply to this message]
|