function check_words($text) { $text=$text; $bad_words = file('c:\deploymentshare$\bad_words.txt'); $bad = explode(" | ",$bad_words[0]); $b = '/\W' . implode('\W|\W', $bad) . '\W/i'; if(preg_match($b, $text)){ echo $text ." - Contain Bad words!"; # - other function here } else{ echo $text ." - Not containing bad words"; # - other function here } }