Can someone help me figure out to do this with PHP?

myscranton

New member
Say I have a variable: $phrase = "The 16th president was Abraham Lincoln".
And I have two sentences:
$sentences[0] = "The 16th president of the US was Abraham Lincoln";
$sentences[1] = "The 1st president was George Washington".

Using PHP, what would be the best way to pick the $sentences that is contains the $phrase.
I can't use strpos because in $sentences[0], the one that should be picked, contains a few words between the $phrase words. Is there anyway to use a wildcard or anything? Any ideas?
Thanks!
 
Back
Top