note 14285 deleted from function.str-replace by philip

From: Date: Mon, 04 Feb 2002 12:51:41 +0000
Subject: note 14285 deleted from function.str-replace by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-26219@lists.php.net to get a copy of this message
When I did some stuff with MySQL here is what I did to make the output more.. friendly when displaying the data. In this example there is "news" data in the database. The $comment variable is where the info is stored in the function I am using. Now since I'm a nutecase, I want to convert every cr/lf (note, this took me hours until it finally dawned on me) into a <br /> (XHTML compliant) and if I had a double <br /> convert that into a new paragraph... Well, here is the code: $comment = str_replace("\r\n","<br />",$comment); $comment = str_replace("<br /><br />","< /p>\n< p>",$comment); Which makes it output pretty nice code, example: < p>Is it true?< br />Does it really work?< /p> < p>REALLY?< /p> < p>No way. I don't believe it.< br />Should you?< /p> Sorry about the space there in the paragraph coding in the coed example itself, and in the html example as well. It's way too late/early for me to fight with this thing. Hope this helps someone else who is up far to late with no caffiene. :)

« previous php.notes (#26219) next »