Jump to content

str_replace or preg_replace, either way it ain't working!!


immanuelx2

Recommended Posts

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.