scripting - PHP strstr difference issue -
so have problem. have snippet of code see if phrase present in phrase:
if(strstr($matches[1], $query))
so example if:
$matches[1] = "arctic white" $query = "arctic"
in case above, code detect phrase "arctic" in phrase "arctic white" although, want detect if inside words , not phrases.
for example if:
$matches[1] = "antarctica" $query = "arctic"
in case script not detect word "arctic" in "antarctica" although is. wondering, how can edit if(strstr($matches[1], $query))
detect words have $query content in it? please help!
you can use preg_match() better result. preg_match doesn't encompass regular expressions only. can need. i.e.:
if (preg_match("/arctic/i", "antarctica")) { // there } else { // not there else }
btw, small "i" means case sensitivity, check php manual more examples: http://php.net/manual/en/function.preg-match.php
Comments
Post a Comment