RobertP Posted March 13, 2012 Share Posted March 13, 2012 How can i disable bbcode inside the code tags?. for example [ code ]test [ b ]bold[/ b ] test[/ code ] the bold is [ b ]bold[/ b ] instead of bold i am not sure how to explain this more clearly. $string = '[b]this[/b] is [b]a[/b] very [b]boldy[/b] message. [url=http://www.google.ca/]click here[/url] or this [url]http://www.google.ca/[/url]'; $bbc = array( 'b'=>array( 'expression'=>'/\[b\](.*?)\[\/b\]/', 'result'=>'<span style=font-weight:bold;>\\1</span>', ), 'url2'=>array( 'name'=>'Link', 'display_in_commands'=>false, 'expression'=>'/\[url=(.*?)\](.*?)\[\/url\]/', 'result'=>'<a href="\\1" target="_blank">\\2</a>', ), 'url'=>array( 'name'=>'Link', 'display_in_commands'=>true, 'expression'=>'/\[url\](.*?)\[\/url\]/', 'result'=>'<a href="\\1" target="_blank">\\1</a>', ) 'code'=>array( 'name'=>'Code', 'display_in_commands'=>true, 'expression'=>'/\[code\](.*?)\[\/code\]/', 'result'=>'<div class="bbc-code-tag">\\1</div>', ), ); $expressions = $results = array(); foreach($bbc as $tag => $code){ $expressions[] = $code['expression']; $results[] = $code['result']; } $string = preg_replace($expressions,$results,$string); $string = str_replace("\r\n",'<br />',$string);//convert line breaks. echo $string; 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.