So currently I have a problem. I have this snippet of code to see if a phrase is present in another phrase:
if(strstr($matches[1], $query))
So for example if:
$matches[1] = "arctic white"
$query = "arctic"
In the case above, the code would detect that the phrase “arctic” is in the phrase “arctic white” although, what I want is for it to detect if it is inside words as well and not just phrases.
For example if:
$matches[1] = "antarctica"
$query = "arctic"
In that case the script would NOT detect the word “arctic” in “antarctica” although it is. So I was wondering, how can I edit if(strstr($matches[1], $query)) so it would detect ALL words that have the $query content in it? Please help!
You can use preg_match() for much better result. The preg_match doesn’t encompass regular expressions only. It can do exactly what you need. i.e.:
btw, the small “i” means case sensitivity, check PHP manual for more examples: http://php.net/manual/en/function.preg-match.php