Which is more efficient, PHP string functions or regex in PHP?

后端 未结 9 1877
甜味超标
甜味超标 2020-12-06 16:48

I\'m writing PHP code to parse a string. It needs to be as fast as possible, so are regular expressions the way to go? I have a hunch that PHP string functions are more expe

9条回答
  •  眼角桃花
    2020-12-06 17:13

    In general, string functions are faster and regex functions are more flexible.

    As with anything else, your results may vary, the only way to know for sure is to try it both ways and benchmark.

提交回复
热议问题