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! Link to comment https://forums.phpfreaks.com/topic/168075-solved-remove-bbcode-from-inside-another-tag/ 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. Link to comment https://forums.phpfreaks.com/topic/168075-solved-remove-bbcode-from-inside-another-tag/#findComment-887342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.