preg_replace换成preg_replace_callback解决方法

WBOY
Release: 2016-06-13 12:26:25
Original
973 people have browsed it

preg_replace换成preg_replace_callback
 function fetch_str($source){
        $source = $this->smarty_prefilter_preCompile($source);
        return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
  }
------解决思路----------------------

return preg_replace_callback("/{([^\}\{\n]*)}/", <br />    function($m) {<br />      return $this->select($m[1]);<br />    }, $source);
Copy after login

分行写只是为了看得清楚

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!