did you mean something like:
$words = array(
"/foo/is",
"/bar/is",
"/baz/is"
);
$myWord = 'hello';
foreach($words as $check) {
if (preg_match($check, $myWord )) {
// do something
}
}
Question
Currently I have a simple swear filter in place with an array of words, I am now also wanting to do checking on strings to see if they contain any:
Here's my list:
$words = array(
"/foo/is",
"/bar/is",
"/baz/is"
);
So I basically want to search a string for any of those words, if it picks up even one of them, then do something.
Is that easily doable?
Solution
did you mean something like:
$words = array(
"/foo/is",
"/bar/is",
"/baz/is"
);
$myWord = 'hello';
foreach($words as $check) {
if (preg_match($check, $myWord )) {
// do something
}
}