PHP code example of vasart / naughty-words
1. Go to this page and download the library: Download vasart/naughty-words 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/ */
vasart / naughty-words example snippets
use VasArt\NaughtyWords\NaughtyWords;
$naughtyWordsEn = NaughtyWords::getForLanguage('en');
use VasArt\NaughtyWords\Validator;
$text = 'some user input with potentially bad words';
$naughtyWordsValidator = new Validator( [ 'en', 'ru' ] );
$naughtyWords = $naughtyWordsValidator->findNaughtyWords( $text );
var_export($naughtyWords); // [ 'en' => 'word', 'ru' => false ]