1. Go to this page and download the library: Download genert/bbcode library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
genert / bbcode example snippets
use Genert\BBCode\BBCode;
$bbCode = new BBCode();
// Output: '[b]Hello word![/b]'
$bbCode->convertFromHtml('<strong>Hello word!</strong>');
use Genert\BBCode\BBCode;
$bbCode = new BBCode();
// Output: '<strong>Hello word!</strong>'
$bbCode->convertToHtml('[b]Hello word![/b]');
use Genert\BBCode\BBCode;
$bbCode = new BBCode();
// Output: 'Hello word!'
$bbCode->stripBBCodeTags('[b]Hello word![/b]');
use Genert\BBCode\BBCode;
$bbCode = new BBCode();
// Output: '<strong>Bold</strong> [i]italic[/i]'
$bbCode->only('bold')->convertToHtml('[b]Bold[/b] [i]italic[/i]');
// Or as array
$bbCode->only(['bold'])->convertToHtml('[b]Bold[/b] [i]italic[/i]');
use Genert\BBCode\BBCode;
$bbCode = new BBCode();
// Output: '[b]Bold[/b] <i>italic</i>'
$bbCode->except('bold')->convertToHtml('[b]Bold[/b] [i]italic[/i]');
// Or as array
$bbCode->except(['bold'])->convertToHtml('[b]Bold[/b] [i]italic[/i]');
use Genert\BBCode\BBCode;
$bbCode = new BBCode();
// Add "[link target=http://example.com]Example[/link]" parser.
$bbCode->addParser(
'custom-link',
'/\[link target\=(.*?)\](.*?)\[\/link\]/s',
'<a href="$1">$2</a>',
'$1'
);
// Output: '<a href="www.yourlinkhere.com">Text to be displayed</a>.'
$bbCode->convertToHtml('[link target=www.yourlinkhere.com]Text to be displayed[/link].');