A
Anonymous
Guest
Rather than try to reinvent the wheel, I suggest checking out HotScripts.com or PHPClasses.org and searching for "bbcode" or "vbcode", as there are several packages that others have created for this purpose.
For bold opening [b]
For bold closing [/b]
For italics opening [b]
For italics closing [/b]
//Now consider you have a string say
$string = "[b]Ruturajv[/b] is my [i]name[/i]";
//Let us replace the string with this
$string = str_replace("[b]", "<b>", $string);
$string = str_replace("[/b]", "</b>", $string);
$string = str_replace("[i]", "<i>", $string);
$string = str_replace("[/i]", "</i>", $string);
This is a very simple method
you can then use arrays and specify everything