1 Vote Vote

PHP - Find if any of the keywords in an array exist in a string

Posted by topdog 284 days ago Questions| keywords array find All

Hello, and first of all, thank you for taking the time to read my question. Basically, I have an array of keywords, and a piece of text. I am wondering what would be the best way to find out if any of those keywords are present in the text, bearing in mind performance issues.

I was thinking of just looping over the array and doing a strpos() for each keyword, but with well over ten thousand words in the array, it takes PHP a bit of time to do it, and so I was wondering if there is a more efficient way to do it.

Thank you in advance, Bruno De Barros.

Discuss Bury


Who Voted for this Question