PHP code example of litlife / json-to-bbcode
1. Go to this page and download the library: Download litlife/json-to-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/ */
litlife / json-to-bbcode example snippets
bash
use Litlife\JsonToBBCode\Renderer;
$jsonString = <<<EOT
{
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Example text using strong",
"marks": [
{
"type": "bold"
}
]
}
]
}
]
}
EOT;
$jsonArray = json_decode($jsonString, true);
$bbCodeString = (new Renderer())->render($jsonArray);
echo ($bbCodeString);