Jump to content

Archived

This topic is now archived and is closed to further replies.

Tandem

bbcode parsing

Recommended Posts

I've been trying to implement bbcode onto my website, but it's not working out. I just don't understand how to do it, and just about all the tutorials i come across are terribly written/wrong.

I did find a custom made file that parses tags, but the if you miss off a closing tag or make a similar mistake, it would destroy the page's layout, and i don't want to user input pages to be able to do that.

Can somebody point me towards some good documentation for using the PEAR bbcode parser or possibly explain how i go about using it themselves?

Thankyou for any help.

Share this post


Link to post
Share on other sites
Please point out any holes in my function but this is a simple version of what i've been using lately:

<?php

function parse_BBCode($input_str) {

  preg_match("#\[b\](.*?)\[b\]#i", $input_str, $matches);
  $input_str = preg_replace("#\[b\](.*?)\[\\b\]#i", "<b>".$matches[1]."</b>", $input_str);

  ... more BBCode->HTML regexs
return $input_str;
  }
?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.