skip navigation

Content:: PHP - BB 2 HTML Function

PHP - BB 2 HTML Function

BB 2 HTML is a function that will convert common bb code [b],[i],[u], etc to html code. This is a very simple version and could use some fine tuning and half parsing. For proper display we realy on the input user to close tags properly. Some error checking in the future would be nice. This should help with a solution to some types of cross site scripting.
The majority of this code is from

Our first step of course is including the file.
if (file_exists("./inc/")) { include ("./inc/"); } else { echo 'failed to open'; exit;}
This portion is a sample string with BB code in it. The string is being parsed by the bb2html function and then echo'ed out for print.
$strConvert = '[b]this is bold[/b]
and here is some [i]italic[/i]';
$strConvert = bb2html($strConvert);
echo $strConvert;
Download 2,305 bytes
MD5 - f02621187ef8381b4f5b85fad82b1edd *
Last Modified: 2012-10-21