I have a phrase: “Tampa Bay Bucs”
I have a sentence: “I have tickets to the football game this Saturday!”
The sentence could be anything.
I want to test whether the phrase is in the sentence.
What is the best way to go about this using PHP?
I have a phrase: “Tampa Bay Bucs”
I have a sentence: “I have tickets to the football game this Saturday!”
The sentence could be anything.
I want to test whether the phrase is in the sentence.
What is the best way to go about this using PHP?
have you tried substr_count()?
you can use preg_match()
substr_count() is much faster and most likely better solution for this problem. Check the documentation on php.net, there are even examples you can copy and paste to make it work with your problem.
First you may need to more clearly define what you want the code to do. For example given the phrase “mike’s ass” and the sentence “we killed mike’s assassin today”, should the phrase be recognised as part of the sentence?
If yes, then look at using strpos(), otherwise more clear rules will need to be defined.