PHP Built in BBCode library?

tenx23

New Member
Messages
25
Reaction score
0
Points
0
Well, since I got told there is a better way to do BBCode than Regex, I wondered how it's done.

I want something like this:

Code:
[a=http://google.com/]Google[/a]

to become something like this:

Code:
<a href="http://google.com/">Google</a>


I couldn't find any tutorials on this anywhere.

Thanks once again,
tenx23.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Did you try following misson's link to the PEAR HTML_BBCodeParser library? Go to the download page there and download the manual install tarball if you want to examine the code.

And keep in mind that there are alternatives to BBCode as well -- Markdown (or Markdown Extra if you need to include things like code blocks), in particular, is a little more user-friendly, since the source text is still intuitively readable (lists look like lists, stressed elements, like <strong> and <em>, are surrounded by asterisks or underscores, etc).
 
Top