sarathi Posted July 30, 2009 Share Posted July 30, 2009 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! Quote Link to comment Share on other sites More sharing options...
sarathi Posted July 31, 2009 Author Share Posted July 31, 2009 Nvm, I found a way to apply tag only when code is not around it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.