检查域名是否包含某些单词

I am trying to check if domain name contain blacklisted words.Below is my code so far

function teststringforbadwords($string,$banned_words) {
    foreach($banned_words as $banned_word) {
        if(stristr($string,$banned_word)){
            return false;
        }
    }
    return true;
}


$banned_words= array("casino","payday","prescription");


if (teststringforbadwords("casino123.com",$banned_words)) {
echo "banned word found";
continue;
} 

Above code works for casino.com but not casino123.com , Any help will be appreciated.

Note : this is not duplicate The question mentioned just check for 1 word , I am checking array of words here.

The condition is pretty much the opposite, should be:

foreach($banned_words as $banned_word) {
    if(stristr($string,$banned_word) !== false){
        return true;
    }
}
return false;

I think your logic is backwards. You want to return true if the banned word is found, right?

if(stristr($string,$banned_word)){
return true;
}

...because, when you call the function you say:

if(teststringforbadwords("casino123.com",$banned_words)){
echo "banned word found";
}