Open Source & Stuff  
  |     Main Site     |      Forum     |     Contact     |
PHP scripting :  forum.Salix.gr forum.Salix.gr
PHP resources. You have a problem with a script? you need a script? If you dont find it here feel free to ask. Have something you want to share? post it here!! 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
messageBBCode to HTML
Posted by: panos (IP Logged)
Date: November 30, 2006 10:19AM

Recently I found a realy good class to convert bbCode to HTML.

[www.phpclasses.org]

Realy easy to use

	include_once("includes/classes/bbcode.inc.php");
	
	function bbCode2HTML($entry) {
		$entry = nl2br($entry);
		$bbcode = new bbcode();
		$bbcode->add_tag(array('Name'=>'b',
                                            'HtmlBegin'=>'<span style="font-weight: bold;">',
                                            'HtmlEnd'=>'</span>'));
		$bbcode->add_tag(array('Name'=>'i',
                                            'HtmlBegin'=>'<span style="font-style: italic;">',
                                            'HtmlEnd'=>'</span>'));
		$bbcode->add_tag(array('Name'=>'u',
                                            'HtmlBegin'=>'<span style="text-decoration: underline;">',
                                            'HtmlEnd'=>'</span>'));
		$bbcode->add_tag(array('Name'=>'red',
                                            'HtmlBegin'=>'<span style="color: red;">',
                                            'HtmlEnd'=>'</span>'));
		return( $bbcode->parse_bbcode($entry) );
	}

What I liked is that you can define the tags you want to convert and even add your own.
Very nice work.



Sorry, only registered users may post in this forum.

All Rights Reserved 2006 Salix.gr  |  Design by Ades Design |  Hosting by e-emporio |  forum.Salix.gr powered by Phorum