1. Go to this page and download the library: Download orionstar/bad-word-filter 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/ */
orionstar / bad-word-filter example snippets
$myString = "Don't be a #FOOBAR!";
$clean = BadWordFilter::clean($myString);
var_dump($clean);
// output: "Don't be a #F****R!"
$myString = "I am an ASSociative professor";
$clean = BadWordFilter::clean($myString);
var_dump($clean);
// output: "I am an ASSociative professor"
$myOptions = ['also_check' => ['foobar']];
$filter = new \orionstar\BadWordFilter\BadWordFilter($myOptions);
$cleanString = $filter->clean('Why did you FooBar my application?');
var_dump($cleanString);
// output: "Why did you F****r my application?"
$filter = new \orionstar\BadWordFilter\BadWordFilter();
if ($filter->isDirty(['this is a dirty string'])
{
/// do something
}
$filter = new \orionstar\BadWordFilter\BadWordFilter();
$string = "this really bad string";
$cleanString = $filter->clean($string);
$string = "this really bad string";
$cleanString = BadWordFilter::clean($string);
$filter = new \orionstar\BadWordFilter\BadWordFilter();
if ($badWords = $filter->getDirtyWordsFromString("this really bad string")) {
echo "You said these bad words: " . implode("<br />", $badWords);
}
$arrayToCheck = [
'first' => [
'bad' => [
'a' => 'This is a bad string!',
'b' => 'This is a good string!',
],
],
'second' => 'bad bad bad string!',
];
$filter = new \orionstar\BadWordFilter\BadWordFilter();
if($badKeys = $filter->getDirtyKeysFromArray($arrayToCheck))
{
var_dump($badKeys);
/* output:
array(
0 => 'first.bad.a',
1 => 'second'
);
*/
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.