Forum Moderators: coopster
[url=LINK title=TITLE]link to foo[/url] [div class=CLASSNAME]div contenet[/ div]
/\[url=(.*?)\](.*?)\[\/url\]/i
function parseBBCode($txt) {
$patterns = array(
'#\[b\](.+)\[\/b\]#iUs',
'#\[url\=(.+)\](.+)\[\/url\]#iUs',
'#\[img\](.+)\[\/img\]#iUs',
'#\[quote\=(.+)\](.+)\[\/quote]#iUs'
);
$replacements = array(
'<b>$1</b>',
'<a href="$1">$2</a>',
'<img src="$1" />',
'<div class="quote_owner">$1 Said:</div><blockquote>$2</blockquote>'
);
return preg_replace($patterns, $replacements, $txt);
}
$string = html_entity_decode($string, ENT_QUOTES);
$markup = array(
'#\[b\](.+)\[\/b\]#iUs' => '<b>$1</b>'
);
$from = array();
$to = array();
foreach ($markup as $a => $b){
$from[] = $a;
$to[] = $b;
}
echo preg_replace($from, $to, $string);
it works even if i remove it..