marcus Posted December 11, 2006 Share Posted December 11, 2006 I am trying to make a contact thing, that just simply puts a row in a database, but how would I go upon checking if the message included swears?Say if I had an array of words that I didn't want the person to send and check if the message included any of those Quote Link to comment Share on other sites More sharing options...
freeloader Posted December 11, 2006 Share Posted December 11, 2006 [code]$a=preg_match_all("/\b(example|example2|example3|example4)\b.*/i",$post,$b);if($a){// block post or whatever}[/code]sufficient? =)[b]edit by neylitalo:[/b] The examples need not be the actual words. :) Quote Link to comment Share on other sites More sharing options...
marcus Posted December 11, 2006 Author Share Posted December 11, 2006 Could this be done with str_replace? If ($a <$a being str_replace($swears,"",$message)){ echo "bad word" }?? Quote Link to comment Share on other sites More sharing options...
.josh Posted December 11, 2006 Share Posted December 11, 2006 or[code]$badwords = array('badword1','badword2','badword3');$needle = 'blah';if (in_array($needle,$badwords)) { // badword found code} else { // badword not found code}[/code] Quote Link to comment Share on other sites More sharing options...
marcus Posted December 11, 2006 Author Share Posted December 11, 2006 Works perfect thanks! Quote Link to comment 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.