What is the fastest way in PHP to take a keyword list and match it to a search result (like an array of titles) for all words?
For instance, if my keyword phrase is “great leather shoes“, then the following titles would be a match…
- Get Some Really Great Leather Shoes
- Leather Shoes Are Great
- Great Day! Those Are Some Cool Leather Shoes!
- Shoes, Made of Leather, Can Be Great
…while these would not be a match:
- Leather Shoes on Sale Today!
- You’ll Love These Leather Shoes Greatly
- Great Shoes Don’t Come Cheap
I imagine there’s some trick with array functions or a RegEx (Regular Expression) to achieve this rapidly.
I would use an index for the words in the titles and test if every search term is in that index: