Code: Select all
<?php
// BBCode Parsing Function...
include("bb_array.php"); // Where the actual BBCode definition table is stored...
function convert_bbcodes( $text )
{
foreach( $GLOBALS['bb_codes'] as $search=>$replace )
{
$text = str_replace( $search,$replace,$text );
}
return $text;
}
?>Code: Select all
<?php
$bb_codes = array(
# bold
'[b]' => '<span style="font-weight:bold">',
'[/b]' => '</span>',
# italic
'[i]' => '<span style="font-style:italic">',
'[/i]' => '</span>',
# underline
'[u]' => '<span style="text-decoration:underline">',
'[/u]' => '</span>',
# colors
'[red]' => '<span style="color:red">',
'[aqua]' => '<span style="color:aqua">',
'[black]' => '<span style="color:black">',
'[blue]' => '<span style="color:blue">',
'[fuchsia]' => '<span style="color:fuchsia">',
'[gray]' => '<span style="color:gray">',
'[green]' => '<span style="color:green">',
'[lime]' => '<span style="color:lime">',
'[maroon]' => '<span style="color:maroon">',
'[navy]' => '<span style="color:navy">',
'[olive]' => '<span style="color:olive">',
'[purple]' => '<span style="color:purple">',
'[silver]' => '<span style="color:silver">',
'[teal]' => '<span style="color:teal">',
'[white]' => '<span style="color:white">',
'[yellow]' => '<span style="color:yellow">',
'[/color]' => '</span>',
'[/colour]' => '</span>', # For our british friends.
# smilies
':)' => '<img src="/images/smiles/icon_smile.gif" />',
':(' => '<img src="/images/smiles/icon_sad.gif" />',
';)' => '<img src="/images/smiles/icon_wink.gif" />',
';>' => '<img src="/images/smiles/icon_twisted.gif" />',
':D' => '<img src="/images/smiles/icon_biggrin.gif" />',
':?' => '<img src="/images/smiles/icon_confused.gif" />',
'8)' => '<img src="/images/smiles/icon_cool.gif" />',
';(' => '<img src="/images/smiles/icon_cry.gif" />',
'#)' => '<img src="/images/smiles/icon_rolleyes.gif" />',
'[?]' => '<img src="/images/smiles/icon_question.gif" />'
);
?>[Edit]
Oops, it seems that phpBB has stripped out and parsed all of my bbcode lol...anyway I am sure you can get the jist from this, if not I'll have to find another way to post the array...