Page 1 of 1

How to replace 2 linebreaks with a paragraph

Posted: Sun Aug 12, 2007 1:55 pm
by trobale
What preg_replace syntax should I use when I want to format a text paragraph (that is delimetered by \n\n) to html paragraph <p></p>.

eg I have the following text:

some text

some more text


to html:

<p>some text</p>
<p>some more text</p>


Thanks

Posted: Sun Aug 12, 2007 2:51 pm
by dustrg
Could you just /g globally replace all "\n\n" with "</p>\n\n<p>" and enclose the resulting string in a "<p>" and "</p>"?

Posted: Sun Aug 12, 2007 3:30 pm
by feyd
There's no /g modifier in PHP's PCRE. That is controlled via secondary parameters.

Posted: Mon Aug 13, 2007 3:40 am
by trobale
What a fool I am!

Thank You