Question 1
I'm using the following to check for bad words from some input element, and i want to tell the user which word on their text is not allowed. How do i get that specific word or words from the array that matched it? And how when user entered more than one bad word this only detects the first word and ignores the rest.
Question 2.
How do i ignore lower and upper cases, this code doesn't recognize "John" and "john" as the same thing. I don't know if this is a regex job. Please reccomend another way if this is weak. PHP
$BadWords = array("James", "June", "Jane");
if (in_array($comment, $BadWords)){
echo 'No way... that is not allowed lol...';
}
Question 3 (Speed)
Say i have around 2000 words to compare a word against, which way is the best to do this process faster without misuse resources while taking into account that filtering bad words is just an example as this is not limited to checking bad words and at all cases not considering databases.
Thanks.