如何將以下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