PHPFront

Home > PHP > Multi BB Codes
The PHP website created by its users!



Multi BB Codes


AuthorJoe
DescriptionAllows [code], [mail] [url=] [color=] [size=] [b] [i] [u] tags.
RatingThis script has been rated 2/5 (24 votes)

PHP Code


<?
function bb_replace($text) {

$text htmlspecialchars($text);
$text stripslashes($text);



$text str_replace("[ar]","<b>&raquo;</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);
*/
?>



Rate it: Print Print

Comments


Joe / 3 Jan 06

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.
Admin / 4 Jan 06

Done.
Name
Website
Your comment