joined:June 30, 2009
I'm stuck on something involving preg_replace. I'm using it to create BBCode on my site. I have a code tag which I use to show how to use the BBCode, but the bbcode inside the code bbcode tags still renders as html.
The code is as follows:
$pattern = "#\[code\](.+?)\[/code\]#is";
$pattern = "#\[info\](.+?)\[/info\]#is";
$replacements = '<pre class="code">$1</pre>';
$replacements = '<div class="informationbox">$1</div>';
$p = preg_replace($pattern, $replacements, $post);
I think I have to change $pattern so it will not change if it is between the code tags. Though I'm hoping it's possible to do that in the code regexp as i have more bbcode than shown here.
Does anyone know how I can about this?
Thanks in advance,