PHP BBCode Parser
<?php
function bbcodeParser($bbcode){
/*
*
*    BBCode Parser
*    Copyright (c) Kenneth Tsang 2011
*
*    Syntax: bbcodeParser(bbcode)
*/
 
/* Matching codes */
$urlmatch = "([a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+)";
 
/* Basically remove HTML tag's functionality */
$bbcode = htmlspecialchars($bbcode);
 
/* Replace "special character" with it's unicode equivilant */
$match["special"] = "/\�/s";
$replace["special"] = '&#65533;';
 
/* Bold text */
$match["b"] = "/\[b\](.*?)\[\/b\]/is";
$replace["b"] = "<b>$1</b>";
 
/* Italics */
$match["i"] = "/\[i\](.*?)\[\/i\]/is";
$replace["i"] = "<i>$1</i>";
 
/* Underline */
$match["u"] = "/\[u\](.*?)\[\/u\]/is";
$replace["u"] = "<span style=\\