php - Is strpos the fastest way to search for a string in a large body of text?

Viewed 25984
if (strpos(htmlentities($storage->getMessage($i)),'chocolate')) 

Hi, I'm using gmail oauth access to find specific text strings in email addresses. Is there a way to find text instances quicker and more efficiently than using strpos in the above code? Should I be using a hash technique?

3 Answers

strpos() return the begin position of first occurrence of string, if no match will return Null so statement is fairly usable.

if (!is_null(strpos($storage->getMessage($i),'chocolate'))) {}
Related