Jump to content

[SOLVED] remove bbcode from inside another tag


sarathi

Recommended Posts

I am trying to stop bbcode tags from working inside of a code tag, and what I have come up with is this:

 

<?php
function tags($text)
{
$var = array('/(\[i\])(.+)(\[\/i\])/Usi','/(\[b\])(.+)(\[\/b\])/Usi');
$rep = array('<i>\\2</i>','<strong>'.rtags('\\2').'</strong>');
return (preg_replace($var, $rep, $text));
}
function rtags($text)
{
$var = array('/(<i>)(.+)(<\/i>)/Usi','/(<strong>)(.+)(<\/strong>)/Usi');
$rep = array('[i]\\2[/i]','[b]\\2[/b]');
return (preg_replace($var, $rep, $text));
}
echo tags("[b]bold[i]italic[/i][/b][i]italic[/i]");
?>

 

This I was hoping would output bold[*i*]italic[/*i*]italic (without the stars)

but instead it output bolditalicitalic.

 

Does anyone know of a way I can fix this, or another method of removing bbcode inside of a tag?

 

Thanks!

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.