AdamH.us

Strip BBCode Function

by on Feb.17, 2012, under Other Stuff, TheScripters, Web Design

While working on a website, I was integrating an Announcements forum section into the front page and needed to strip away BBCode that was wreaking havoc with displaying only a hundred of the first characters of a post. This is what I came up with (didn’t bother searching online for something else, either)…

I didn’t feel like going through the process of instantiating phpBB’s BBCode class because that would require a pretty lengthy file. So, I just used a basic BBCode function instead. But I think it’d probably be easier to just strip out the tags altogether, which is what phpBB does. If you can figure out how to use it, it would probably be better. It uses preg_replace() to strip out the BBCode, where my example simply converted the BBCode to HTML and used PHP’s own HTML stripping functions.

© 2012, AdamH.us. All rights reserved. Please link back if you use it!

:, , , ,

Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!