Cloud Ghost
09-11-2011, 02:56 AM
Hello, I recently built a comment system and I added BBCode to it today but I ran into a problem. I want to have a [code] tag so I used preg_replace() with something similar to this:
$message = preg_replace("/(\[b\])(.+)(\[\/b\])/s", "<b>$2</b>", $message);
The problem is, I also have smilies and I use str_replace() for those so the smilies (and other BBCode) will get parsed inside the [code] tag which I do not want. I don't want the user to be able to disable BBCode or smilies so is there a way for the [code] tag to be processed differently than the other tags and stop smilies and other BBCode from being parsed?
$message = preg_replace("/(\[b\])(.+)(\[\/b\])/s", "<b>$2</b>", $message);
The problem is, I also have smilies and I use str_replace() for those so the smilies (and other BBCode) will get parsed inside the [code] tag which I do not want. I don't want the user to be able to disable BBCode or smilies so is there a way for the [code] tag to be processed differently than the other tags and stop smilies and other BBCode from being parsed?