如何将以下preg_replace转换为preg_replace_callback?已弃用:preg_replace():如何转换为preg_replace_callback?
$this->template = preg_replace ("#\\[group=(.+?)\\](.*?)\\[/group\\]#ies",
"\$this->check_group('\\1', '\\2')", $this->template);
我已经试过:
$this->template = preg_replace_callback("#\\[not-group=(.+?)\\](.*?)\\[/not-group\\]#ies",
function($this) {
return $this->check_group($this[1], $this[2], false);
}
, $this->template);
和上述preg_replace_callback给我一个空的结果。
您是否可以在问题中更新测试数据和预期输出? –
它似乎在php5.5中不能使用e修饰符。将'#ies'改为'#isu',现在它正在工作 – Orlo