Home  >  Article  >  Backend Development  >  preg_match_all 性能低.效率差.有其它办法吗???

preg_match_all 性能低.效率差.有其它办法吗???

WBOY
WBOYOriginal
2016-06-23 14:23:491019browse

原来用preg_replace_callback发现效率低.
改成preg_match_all  + str_replace
str_replace几乎不花时间. preg_match_all执行一次要花0.5秒以上.


回复讨论(解决方案)

那肯定是正则匹配花的时间长,贴出代码瞧瞧。

preg_match_all("/(\"|\'|=)\/column.php\?cid=(\d+)&s(\d+)=(\d+)&page=(\d+)/i", $result, $m);


不会是用  | 或的原因吧?

我吊啊.真是这鸟原因啊

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP的C扩展如何调用第三方库Next article:问个问题