1. Go to this page and download the library: Download jcrowe/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/ */
jcrowe / 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 = array('strictness' => 'permissive', 'also_check' => array('foobar'));
$filter = new \JCrowe\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 \JCrowe\BadWordFilter\BadWordFilter();
if ($filter->isDirty(array('this is a dirty string')) {
/// do something
}
$filter = new \JCrowe\BadWordFilter\BadWordFilter();
$string = "this really bad string";
$cleanString = $filter->clean($string);
$string = "this really bad string";
$cleanString = BadWordFilter::clean($string);
$filter = new \JCrowe\BadWordFilter\BadWordFilter();
if ($badWords = $filter->getDirtyWordsFromString("this really bad string")) {
echo "You said these bad words: " . implode("<br />", $badWords);
}
$arrayToCheck = array(
'first' => array(
'bad' => array(
'a' => 'This is a bad string!',
'b' => 'This is a good string!',
),
),
'second' => 'bad bad bad string!',
);
$filter = new \JCrowe\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.