我有一些像这样的代码(这是一个简单的例子):在preg_replace_callback中指定回调函数?
function callback_func($matches) {
return $matches[0] . "some other stuff";
}
function other_func($text) {
$out = "<li>";
preg_replace_callback("/_[a-zA-Z]*/","callback_func",$desc);
$out .= $desc ."</li> \r\n";
return $out;
}
echo other_func("This is a _test");
这样做的输出应该
<li>This is a _testsome other stuff</li>
,但我只是得到
<li>This is a _test</li>
我是什么做错了/为了安抚php神,需要什么奇怪的咒语?
哎呀,应该刷新。在你做完之后就想出来了。不管怎么说,还是要谢谢你。 – 2009-09-21 22:48:47