PDA

View Full Version : bbcode parser



Master_script_maker
12-31-2007, 10:42 PM
I have made a simple php bbcode parser that recognizes
[ b ],[ i ], [ u ], [ url ], [ url= ], [ align= ], [ img ], [ img= ], [ email ], [ email= ], [ font= ], [ size= ], [ color= ], [ quote ], [ code ], [ php ]
(without the spaces)
The function returns a value so use:
$var=bbcode_format($text);
Demo: http://masterproject.freehostia.com/bbcode/bbcode.php
Code: http://masterproject.freehostia.com/bbcode/parser.txt

djr33
12-31-2007, 11:38 PM
Very nice. And regex. Beats mine by far.

thetestingsite
12-31-2007, 11:42 PM
you may want to add something in there to parse newlines. Something like nl2br would work, but you could also parse it yourself. Overall, very nice script.

Hope this helps.

Master_script_maker
01-01-2008, 12:25 AM
thanks, i added nl2br.