Basically, I have an array of keywords, and a piece of text. I am wondering what would be the best way to find out if any of those keywords are present in the text, bearing in m
Assuming the formatting and only that you care if any (not which) of the keywords exist, you could try something like:
$keywords = array( "dog", "cat" );
// get a valid regex
$test = "(\b".implode( "\b)|(\b", $keywords )."\b)";
if( preg_match( $test, "there is a dog chasing a cat down the road" ) )
print "keyword hit";