0
function anchor($text)
{
return preg_replace('#\>\>([0-9]+)#','<span class=anchor><a href="#$1">>>$1</a></span>', $text);
}
这段代码用于渲染页面定位点。 我需要使用如何使用preg_replace模式的一部分作为变量?
([0-9]+)
部分作为一个变量做一些数学定义为href标记的确切地址。 谢谢。
不要使用的preg_replace然后。使用preg_match并对结果执行一些操作。 – sberry 2012-07-09 03:35:25
['preg_replace_callback'](http://de.php.net/preg_replace_callback)是你的朋友。 – ccKep 2012-07-09 03:49:53