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 Link to comment https://forums.phpfreaks.com/topic/30283-how-would-i-do-this/ 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. :) Link to comment https://forums.phpfreaks.com/topic/30283-how-would-i-do-this/#findComment-139340 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" }?? Link to comment https://forums.phpfreaks.com/topic/30283-how-would-i-do-this/#findComment-139346 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] Link to comment https://forums.phpfreaks.com/topic/30283-how-would-i-do-this/#findComment-139347 Share on other sites More sharing options...
marcus Posted December 11, 2006 Author Share Posted December 11, 2006 Works perfect thanks! Link to comment https://forums.phpfreaks.com/topic/30283-how-would-i-do-this/#findComment-139355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.