preg_replace 问题,求帮助
<br /><?php <br />$wupin="A类别0::::::品名1::::::品牌/厂商2::::::规格3::::::要改变的数量4::::::单位5::::::单价6::::::要改变的总价7|||||||B类别0::::::品名1::::::品牌/厂商2::::::规格3::::::要改变的数量4::::::单位5::::::单价6::::::要改变的总价7";<br /><br />$strrpos_start="A类别0::::::品名1::::::品牌/厂商2::::::规格3::::::";//查询前面部分<br />$strrpos_end="单位5::::::单价6::::::";//查询后面部分<br /><br />$k =$strrpos_start;<br />$n =10;<br />echo preg_replace("/(?<=$k )\d+/e", '0 + '.$n, $wupin);//行不通,出错<br />?><br /><br />
$wupin="A类别0::::::品名1::::::品牌/厂商2::::::规格3::::::要改变的数量4::::::单位5::::::单价6::::::要改变的总价7<br><font color='#FF8000'>------解决思路----------------------</font><br>B类别0::::::品名1::::::品牌/厂商2::::::规格3::::::要改变的数量4::::::单位5::::::单价6::::::要改变的总价7";<br /> <br />$ep = explode('<br><font color='#FF8000'>------解决思路----------------------</font><br>', $wupin);<br />if($ep[0][0] == 'A'){<br /> $ep[0] = preg_replace_callback("/(要改变的数量)(\d)/", create_function('$matches','return $matches[1].($matches[2]+10);'), $ep[0]);<br />}<br />echo join($ep);