Page 1 of 1

how would i add a bbcode function?

Posted: Mon Dec 29, 2008 4:46 pm
by grgwhl

Code: Select all

function topic($input){
//bbcode
   return nl2br(strip_tags(stripslashes(htmlspecialchars($input))));
}
there is my function where my bbcode code should go, but i wouldn't know how to do it.

Re: how would i add a bbcode function?

Posted: Tue Dec 30, 2008 1:49 am
by Andrewrun
Check out phpbb. It's open source, so you can plug through that.

Basically, you're going to want to do a whole slew of preg_replace's for each of the possible bbcodes that you're going to allow.

For example, to replace you could do something like:
preg_replace('%\[color=(.*)\]%',\1);