preg_replace 的/e有关问题

WBOY
Release: 2016-06-13 12:27:23
Original
978 people have browsed it

preg_replace 的/e问题
由于新版PHP不能用/e,下面这句要怎么改才正常

preg_replace("/(?正常执行结果是:类别0::::::品名1::::::品牌厂商2::::::规格3::::::1::::::单位5::::::9::::::0
去掉/e,结果变成了:类别0::::::品名1::::::品牌厂商2::::::规格3::::::1::::::单位5::::::10-1::::::0

目的是让内容的原数量减新内容的数量,所以这10和1不是固定的.
------解决思路----------------------
对于

$morefrf[6]=1;<br />preg_replace("/(?<=$so)\d+/eis", '$0 - '.$morefrf[6], $rs,1);
Copy after login

要改写为
$morefrf[6]=1;<br />preg_replace_callback("/(?<=$so)\d+/is", function($m) use($morefrf) { return $m[0] - $morefrf[6]; }, $rs,1);
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