由于某种原因,我的preg_replace调用不起作用,我已经检查了一切我能想到的无济于事。有什么建议么?php preg_replace没有做任何事情
foreach ($this->vars as $key=>$var)
{
preg_replace("/\{$key\}/", $var, $this->tempContentXML);
}
瓦尔是包含$键 - >值,该值需要在字符串中被替换的阵列,tempContentXML是包含XML数据的字符串。
一块串
...<table:table-cell table:style-name="Table3.B1" office:value-type="string"><text:p text:style-name="P9">{Reference}</text:p></table:table-cell></table:table-row><table:table-row table:style-name="Table3.1"><...
EX的。
$this->vars['Reference'] = Test;
foreach ($this->vars as $key=>$var)
{
preg_replace("/\{$key\}/", $var, $this->tempContentXML);
}
应该替换字符串引用冲与数组中的价值在$关键
但它无法正常工作。
这个循环是非常低效的。使用preg_replace_callback和数组查找。 – mario