Open vahid-vahid opened 7 years ago
@ConsoleTVs This is The Way I solved it The problem was strtolower does not work on MultiByte characters So I used the method mb_stripos(and is_Numeric to find if it returned something other than false):
public function badWords() { return collect($this->dictionary)->filter(function ($value) { return is_numeric(mb_stripos($this->text, $value['word'])); })->map(function ($value) { return [ 'language' => $value['language'], 'word' => $value['word'], ]; })->toArray(); }
Hello @v01061374 Does this solution work with other languages?
If so, I would recommend you to make a pull request, so we can all benefit ^^
Yes it works
The only change I made is what i mentioned before
Feel free to make a pull request :p
Hi again I want to insert an array of Persian and Arabic dictionary array and get the badwords
The text cleanness is discovered correctly but the badwords function returns unknown characters
$bad = Profanity::blocker('فحش است')->dictionary([['language' => 'fa' , 'word' => 'فحش' ]])->badWords();
returns
array (size=1) 0 => array (size=2) 'language' => string 'fa' (length=2) 'word' => string '������' (length=6)
Please help me with this problem Thank you