Page 1 of 1

BB Code

Posted: Tue Dec 30, 2003 12:40 am
by Dale
Im making me own forum, experimenting with all different codes and things, but i just cant seem to find anything that converts BB Code into HTML:
eg, ( Text --> <b>Text</b> -->Text )

Could someone please help me ;)

Posted: Tue Dec 30, 2003 2:36 am
by m3mn0n
Sure. See my reply here:

viewtopic.php?t=16068

Instead of 'msn' and the link to it, add '[b]' and '<b>'.

Posted: Tue Dec 30, 2003 7:51 am
by McGruff
Check out str_replace.

Search & replace arrays:

$search = array('[ b]', '[ /b]', ..etc..);

$replace = array('<b>', '</b>', ..etc..);

Remember that each $search value is replaced by the $replace value at the same position so order is important.

String functions are preferred to regex, unless you really need it.