<?php include('./classBBCode.php'); $bbcode = new bbcode(1); //1 to enable, 0 to disable bbcode
//first example - usage of pre-defined tags $text = $bbcode->parse('Sample text[br]New line in my sample text[br][br]Maybe I would like to see something in [b]bold[/b]?'); echo $text; /* this will print:
------------- Sample text New line in my sample text
Maybe I would like to see something in blod? ------------- html code: ------------- Sample text<br />New line in my sample text<br /><br />Maybe I would like to see something in <strong>blod</strong>? ------------- */
//second example - create own tag and use it! $bbcode->addTag('d', 'list', 'ul'); //create the ul tag (list) $bbcode->addTag('s', 'li', 'li'); //create the li tag (position on list)
$text = $bbcode->parse('[list][li]Position 1[li]Second position[/list]'); echo $text; /* this will print:
------------- *Position 1 *Second position ------------- html code: ------------- <ul><li />Position 1<li />Second position</ul> ------------- */ ?>
|