PHP code example of ivuorinen / bbcodeparser

1. Go to this page and download the library: Download ivuorinen/bbcodeparser 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/ */

    

ivuorinen / bbcodeparser example snippets


$bbcode = new ivuorinen\BBCode\BBCodeParser();

echo $bbcode->parse('[b]Bold Text![/b]');
// <strong>Bold Text!</strong>

$bbcode = new ivuorinen\BBCode\BBCodeParser();

echo $bbcode
    ->only('bold', 'italic')
    ->parse('[b][u]Bold[/u] [i]Italic[/i]![/b]'); // <strong>[u]Bold[/u] <em>Italic</em>!</strong>

echo $bbcode
    ->except('bold')
    ->parse('[b]Bold[/b] [i]Italic[/i]'); // [b]Bold[/b] <em>Italic</em>

$bbcode = new ivuorinen\BBCode\BBCodeParser();

// Case insensitive
echo $bbcode->parse('[b]Bold[/b] [I]Italic![/I]', true); // <strong>Bold</strong> <em>Italic!</em>

// Or like this:
echo $bbcode->parseCaseInsensitive('[b]Bold[/b] [i]Italic[/i]'); // <strong>Bold</strong> <em>Italic!</em>

$bbcode = new ivuorinen\BBCode\BBCodeParser();

echo $bbcode->parseCaseSensitive('[b]Bold[/b] [I]Italic![/I]'); // <strong>Bold</strong> [I]Italic![/I]

$bbcode = new ivuorinen\BBCode\BBCodeParser();

echo $bbcode->stripBBCodeTags('[b]Bold[/b] [i]Italic![/i]'); // Bold Italic!

'ivuorinen\BBCode\BBCodeParserServiceProvider'

'BBCode' => 'ivuorinen\BBCode\Facades\BBCodeParser'

// Simple parsing
echo BBCode::parse('[b]Bold Text![/b]');

// Limiting the parsers with the only method
echo BBCode::only('bold', 'italic')
        ->parse('[b][u]Bold[/u] [i]Italic[/i]![/b]'); // <strong>[u]Bold[/u] <em>Italic</em>!</strong>

// Or the except method
echo BBCode::except('bold')
        ->parse('[b]Bold[/b] [i]Italic[/i]'); // [b]Bold[/b] <em>Italic</em>