PHP code example of michalskoula / remove-formatting
1. Go to this page and download the library: Download michalskoula/remove-formatting 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/ */
michalskoula / remove-formatting example snippets
use MichalSkoula\RemoveFormatting\Remover;
use MichalSkoula\RemoveFormatting\RemoverOptions;
// create options object (optional)
$options = new RemoverOptions();
// add <u> to the default list of allowed elements
$options->addAllowedElement('u');
// add class to the default list of allowed attributes
$options->addAllowedAttribute('class');
// create Remover object
$remover = new Remover($options);
$dirtyHtml = 'some dirty <span>spans</span> ...';
// run it and get clean html with only allowed elements and attributes
$cleanHtml = $remover->remove($dirtyHtml);