1. Go to this page and download the library: Download diego-ninja/banthis 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/ */
diego-ninja / banthis example snippets
use Ninja\BanThis\Censor;
use Ninja\BanThis\Dictionary;
$dictionary = Dictionary::withLanguage('en-us');
$censor = new Censor($dictionary);
$string = $censor->clean('A very offensive string with the bad word dick on it');
print_r($string)
Array
(
[orig] => A very offensive string with the bad word dick on it
[clean] => A very offensive string with the bad word **** on it
[matched] => Array
(
[0] => dick
)
)
// Set a new dictionary
$censor->setDictionary($dictionary);
// Add words from another dictionary
$additionalDictionary = Dictionary::withLanguage('fr');
$censor->addDictionary($additionalDictionary);