jasonc Posted August 27, 2016 Share Posted August 27, 2016 function checkUsernameIsCleanOfBadWords($string) { $badWords = "["; $badWords.= "ARSE|"; $badWords.= "*******|"; $badWords.= "*****|"; // i $badWords.= "B1TCH|"; // one $badWords.= "BLTCH|"; // L $badWords.= "BOLLOCKS|";// oh oh $badWords.= "BOLL0CKS|";// oh zero $badWords.= "B0LLOCKS|";// zero oh $badWords.= "B0LL0CKS|";// zero zero $badWords.= "****|"; // oh $badWords.= "C0CK|"; // zero $badWords.= "CLIT|"; // L i $badWords.= "CIIT|"; // i i $badWords.= "CILT|"; // i L $badWords.= "CLLT|"; // L L $badWords.= "C11T|"; // one one $badWords.= "CL1T|"; // L one $badWords.= "C1LT|"; // one L $badWords.= "****|"; $badWords.= "dickhead|";// i $badWords.= "dLckhead|";// L $badWords.= "d1ckhead|";// one $badWords.= "fanny|"; $badWords.= "****|"; $badWords.= "gay|"; $badWords.= "lesbian|"; // i $badWords.= "lesbLan|"; // L $badWords.= "lesb1an|"; // one $badWords.= "*****|"; // i $badWords.= "pen1s|"; // one $badWords.= "penls|"; // L $badWords.= "pOOf|"; // oh oh $badWords.= "pO0f|"; // oh zero $badWords.= "p0Of|"; // zero oh $badWords.= "p00f|"; // zero zero $badWords.= "prick|"; // i $badWords.= "pr1ck|"; // one $badWords.= "prLck|"; // L $badWords.= "rape|"; $badWords.= "****|"; // i $badWords.= "sh1t|"; // one $badWords.= "shLt|"; // L $badWords.= "wank]"; if(preg_match(strtolower($badwords), strtolower($string))) { return "bad"; } return "ok";}if (checkUsernameIsCleanOfBadWords($username) === "bad") {// tell them so.} Quote Link to comment https://forums.phpfreaks.com/topic/302021-how-do-i-correctly-check-a-string-for-bad-words/ Share on other sites More sharing options...
Jacques1 Posted August 27, 2016 Share Posted August 27, 2016 (edited) The OP likes to post his questions on many different forums at the same time. This has already been answered on CodingForums ($badWords isn't $badwords). Edited August 27, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/302021-how-do-i-correctly-check-a-string-for-bad-words/#findComment-1536739 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.