Here\'s a snippet from my forum code:
<?php
$BB_codes = array(
\'[b]\' => \'<b>\',
\'[/b]\' => \'</b>\',
\'[i]\' => \'<i>\',
\'[/i]\' => \'</i>\',
\'[u]\' => \'<u>\',
\'[/u]\' => \'</u>\',
\'[url]\' => \'<a href=\',
\'[/url]\' => \'>link</a>\',
\'[quote]\' => \'<table border=\"0\" width=\"100%\" cellspacing=\"8\" cellpadding=\"2\"><tr><td width=\"100%\" bgcolor=\"#F2F2F2\"><strong>quote:</strong><br>\',
\'[/quote]\' => \'</td></tr></table>\',
\':)\' => \'<img src=\"images/smiley_happy.gif\">\',
\':(\' => \'<img src=\"images/smiley_sad.gif\">\'
);
function parseToHTML($text)
{
$search = array_keys($GLOBALS[\'BB_codes\']);
$t = str_replace($search, $GLOBALS[\'BB_codes\'], $text);
return $t;
}
echo parseToHTML(\"Here, try something [b]bold[/b] or perhaps [u]underlined[/u] :) :(\");
echo \"<br>\";
echo parseToHTML(\"[u][i][b]How about something bold, underlined, and italicized![/b][/i][/u]\");
echo parseToHTML(\"<br>testing a hyperlink: <br>[url]http://yahoo.com[/url]\");
$message = preg_replace(\"#\\[url=(http://)?(.*?)\\](.*?)\\[/url\\]#si\", \"<A HREF=\\\"http://\\\\2\\\" target=\\\"_blank\\\">\\\\3</A>\", \"[url=www.phpbb.com]phpBB[/url]\");
echo \"<br>\".$message.\"<br>\";
echo parseToHTML(\"[quote]just a routine test.
wanna see how well this stuff really works![/quote]\");
?>
Your signature has been erased by a mod because it's larger than 600x120...