Jump to content

bbcode parsing


Tandem

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.
Link to comment
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;
  }
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.