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

后端 未结 3 1530
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 21:43
if (strpos(htmlentities($storage->getMessage($i)),\'chocolate\')) 

Hi, I\'m using gmail oauth access to find specific text strings in email addr

3条回答
  •  日久生厌
    2021-01-03 22:05

    strpos is likely to be faster than preg_match and the alternatives in this case, the best idea would be to do some benchmarks of your own with real example data and see what is best for your needs, although that may be overdoing it. Don't worry too much about performance until it starts to become a problem

提交回复
热议问题