jdock1 Posted June 17, 2009 Share Posted June 17, 2009 Im trying to set up a swear word filter, one where when the user enters the swear word into the text box is echos an error This is what I have: if ($query == "shit || fuck || titties || penis || vagina") { echo "No swearing"; } I also tried setting up this array: $swearwords = array("swearword", "badword", "anotherswearword", "anotherbadword"); And used this if statement: if ($query == "$swearwords") { echo "No swearing"; } Im somewhat a beginner in PHP and thought this would work but Im probably just an idiot. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/162650-why-is-this-not-working/ Share on other sites More sharing options...
ldougherty Posted June 17, 2009 Share Posted June 17, 2009 assuming your input box sends the value of $query $swearwords = array("swearword", "badword", "anotherswearword", "anotherbadword"); if (in_array($query,$swearwords)) { echo "No swearing"; } Link to comment https://forums.phpfreaks.com/topic/162650-why-is-this-not-working/#findComment-858418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.