SOLVED: Using Answer from Michael Thompson and "Duplicate" Question Users Flagged
All of the code used below is in PHP!
This is not the same as other questions asked on Stack Overflow I have tried the examples people have linked and nothing will work for me!
Prior to Asking on StackOverflow
I've googled this quite a few times, and tried many different tutorials, all of them being different from the other and making it more confusing. Using code like preg_match(), strpos() etc. and can't get it quite right.
Main Question:
I have a registration form on my site. For example, if the user were to sign up with a username like Bad or BadWord, I want it to stop them from doing so.
I have an array of bad words:
$badWords = array('some', 'bad', 'words');
My username variable is:
$username
I want to do a check, for example, if Bad or BadWords contains a word from the array, if it does then it will echo 'bad word detected!'
Pseudo code for example:
if ($username contains $badWords) {
echo 'bad word detected!';
}
I don't have the greatest knowledge of PHP as I only began to learn it a few months ago, that is why I am asking for help.
Thanks!