0
创建模板我有一个字符串,它看起来是这样的:正则表达式替换PHP
{{imagename.jpg|left|The caption for this image. Includes a variety of chars}}
<p>Some text, lots of paragraphs here.</p>
{{anotherimage.jpg|right|Another caption.}}
我试图做的是分析出{{}}
位,然后通过函数传递参数。我至今是:
function template_function($matches) {
print_r($matches);
}
function parse_images($string) {
$string = preg_replace_callback('!\{\{([^}])\}\}!', 'template_function', $string);
return $string;
}
能有人给我一只手用正则表达式,使我最终被通过print_r
运行比赛吗?
所以,我错过了流血*!我知道我必须快到了!这就是为什么Stack Overflow非常棒 - 让别人浏览你的代码非常有用。 – 2011-12-17 21:27:09