BBCode parser.
Version 1.x is incompatible with version 0.9.x.
- PHP 7.3.0+
Include Parserus.php
or install the composer package.
$parser = new Parserus();
echo $parser->addBBCode([
'tag' => 'b',
'handler' => function($body) {
return '<b>' . $body . '</b>';
}
])->addBBcode([
'tag' => 'i',
'handler' => function($body) {
return '<i>' . $body . '</i>';
},
])->parse("[i]Hello\n[b]World[/b]![/i]")
->getHTML();
#output: <i>Hello<br><b>World</b>!</i>
More examples in the wiki.
This project is under MIT license. Please see the license file for details.