|
Multi BB Codes
| Author | Joe |
| Description | Allows [code], [mail] [url=] [color=] [size=] [b] [i] [u] tags. |
| Rating | (24 votes) |
PHP Code
<?
function bb_replace($text) {
$text = htmlspecialchars($text);
$text = stripslashes($text);
$text = str_replace("[ar]","<b>»</b>",$text);
$find = array(
'#[code](.+?)[/code]#is',
'#[mail](.+?)[/mail]#is',
'#[url=(.+?)](.+?)[/url]#is',
'#[color=(.+?)](.+?)[/color]#is',
'#[size=(.+?)](.+?)[/size]#is',
'#[b](.+?)[/b]#is',
'#[i](.+?)[/i]#is',
'#[u](.+?)[/u]#is',
);
$replace = array(
'<div class="title">[b]Code:[/b]</div><div class="core">
<code style="white-space:nowrap">\1</span></div>',
'<a href="mailto:\1">\1</a>',
'<a href="\1">\2</a>',
'<font color="\1">\2</font>',
'<font size="\1">\2</font>',
'<strong>\1</strong>',
'<i>\1</i>',
'<u>\1</u>',
);
$text = preg_replace($find,$replace,$text);
return $text;
}
/*
Now when you want something replaced with the bb code use
$message=$_POST[message];
$message=bb_replace($message);
*/
?>
Comments
can you remove
$text=imagesize($text);
$text = nl2br($text);
$text=smilies_replace($text);
$text=swear_filter($text);
those were going to be additions that I was going to add but i never did, please remove them please.
Done.
|