我想在body標籤後面的內容上使用shortcode函數。如何使用preg_replace反向引用而不是preg_match和preg_replace?
preg_match("/<body[^>]*>(.*?)<\/body>/is", $html, $matches);
$html= preg_replace("/<body[^>]*>(.*?)<\/body>/is",run_shortcodes($matches[1]), $body);
echo $html;
這工作正常,但我想這樣做preg_replace反向引用,如果可能的話。
我已經試過這樣的事情,但顯然這是錯誤的
$html= preg_replace("/<body[^>]*>(.*?)<\/body>/is",run_shortcodes('$1'), $body);
可有人請出示使用反向引用的一個可能的例子。
任何幫助表示讚賞。