I am trying to check a URL, to see if it has any matching terms from my array.
My code is:
function test_string_in_url () {
$the_url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$my_array = array(
'word1',
'word2',
'word3',
);
if (strpos( $the_url, $my_array ) !== false)
// do something
else {
// do nothing
}
}
This always returns false though, which is incorrect. It should only return true because I do have matching terms in my URL, so I must be doing something wrong here...