BB Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

BB Code

Post 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 ;)
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Sure. See my reply here:

viewtopic.php?t=16068

Instead of 'msn' and the link to it, add '[b]' and '<b>'.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
Post Reply