Interpreting BB Code from phpbb forum

Discussion in 'PHP' started by emitind, May 26, 2006.

  1. #1
    Firstly, I've had a look on the phpbb website forum but the search is a bit dense there and I get swamped with thousands of results, none of which have helped me.

    So, quite simply, I would like to replace the bb code from forum posts into standard HTML using PHP so I can display (formatted) posts elsewhere on my website. At the moment, the post is full of BB code.

    I know that str_replace would easily reverse the bb code but I was just wondering if there is someplace or script that does this for all bb code instead of me going through all of it myself. Plus, some are quite complex.

    Thanks :)
     
    emitind, May 26, 2006 IP
  2. infin8

    infin8 Peon

    Messages:
    42
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    phpbb is opensource, so you can simply use its module. Download the source, study the code a little, find the set of functions it uses, and copy it into your code. It's a little tricky at first, but it'll be good knowledge to see some of the techniques they use.

    Otherwise if you want to do it on your own, you'll want to use preg_replace() rather than str_replace(). If you don't know regular expressions already, do a search on google for regex. It will be a valuable skill for the future.
     
    infin8, May 26, 2006 IP