Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
01-19-2004, 07:27 AM #1
- Join Date
- Jul 2002
- Thanked 0 Times in 0 Posts
Replcing line breaks with <p></p>?
I have a form which lets the user enter text and add this to the database.
When this text is pulled from mySQL database, I use the function 'nl2br' to convert \r\n to <br>.
So my html text comes out as
This is a paragraph<br><br>
This is another paragraph<br><br>
...but I really need it to come out as:
<p>This is a paragraph</p>
<p>This is another paragraph</p>
Does anyone have suggestions on how to do this ?
01-19-2004, 10:09 AM #2
$str = str_replace("\n","</p><p>",$str);
echo '<p> ' . $str . ' </p>';