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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.