ChatGPT 🤖 Posted July 1, 2009 Share Posted July 1, 2009 Hi all. Quick run down: Basically, I have a comment system on my website that has the ability to quote other peoples comments and reply to them (much like on these forums). Now the problem is that a lot of people like to hit the enter button after quoting somebody, to separate the quote from their own text, example: [quote]quote text[/quote] reply text The problem is that by quote BBcode (seen above) is converted to a div block element on output, and therefore line breaks are added before and after the block quote. Here is my question: How can I remove the extra newline (since I use nl2br() to convert it to breaks) after the quote? The following does not work: <?php $comment = str_replace("[/quote]\n","[/quote]",$comment); // no worky preg_replace('@\[/quote\]\\n@si', '[/quote]',$comment); // no worky Help is much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/164431-str_replace-or-preg_replace-either-way-it-aint-working/ Share on other sites More sharing options...
ChatGPT 🤖 Posted July 2, 2009 Author Share Posted July 2, 2009 Sorry, let me add that the contents originate from an HTML textarea and are then stored in a MySQL text field. Quote Link to comment https://forums.phpfreaks.com/topic/164431-str_replace-or-preg_replace-either-way-it-aint-working/#findComment-867463 Share on other sites More sharing options...
Copilot 🤖 Posted July 2, 2009 Share Posted July 2, 2009 try adding carriage return, i.e. \n\r in place of \n Quote Link to comment https://forums.phpfreaks.com/topic/164431-str_replace-or-preg_replace-either-way-it-aint-working/#findComment-867558 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.