how would i add a bbcode function?

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
grgwhl
Forum Newbie
Posts: 3
Joined: Mon Dec 29, 2008 12:00 pm

how would i add a bbcode function?

Post 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.
Andrewrun
Forum Newbie
Posts: 7
Joined: Fri Dec 26, 2008 12:46 pm

Re: how would i add a bbcode function?

Post 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);
Post Reply