carlg Posted August 6, 2008 Share Posted August 6, 2008 One of my websites allows public users to fill out a web based form and the form information gets sent on in an email. This is totally getting spammed. I figure I could create my own little spam filter. All I need is a "Dirty word" list which I can easily make myself and the ability to use grep. Let's say I place all of my dirty words in a file called dw.txt The message part of the mail is stored in a variable called $message If I was writing a shell script I could do something like the following: if [ $(grep -f dw.txt $message) -ne "" ] then #THIS IS SPAM fi The only way I see to do this with php is to read the contents of the file into an array with the file command. Loop through the array of dirty words and use preg_grep for each iteration. Does anyone have a better way to do this than to loop through each line of the file? Thanks for the help! Carl Link to comment https://forums.phpfreaks.com/topic/118358-string-searching/ Share on other sites More sharing options...
trq Posted August 6, 2008 Share Posted August 6, 2008 Does anyone have a better way to do this than to loop through each line of the file? There really isn't a better way, no grep in php. Link to comment https://forums.phpfreaks.com/topic/118358-string-searching/#findComment-609107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.