PHP code example of sworup / profanityfilter

1. Go to this page and download the library: Download sworup/profanityfilter 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/ */

    

sworup / profanityfilter example snippets

config/profanity-filter.php
'Profanity'         => 'Sworup\ProfanityFilter\Profanity'
 php
$swear_word = ['dog'];
$blacklist  = ['puppy'];
$replace    = ['a' => '(a|a\.|a\-|4|@|Á|á|À|Â|à|Â|â|Ä|ä|Ã|ã|Å|å|α|Δ|Λ|λ)'];

$profanity_filter = new sworup\ProfanityFilter($swear_words, $blacklist, $replace);
echo $profanity_filter->clean('Dog, puppy badpuppy baddog!', '$');

 php
array(
    'old_string' => 'Dog, puppy badpuppy baddog!',
    'new_string' => '$$$, $$$$$ badpuppy bad$$$!',
    'clean'      => false
);