$lang_string = preg_replace_callback('/[LINK:([^:]+):([^:]+)](.+)[\/LINK]/m', function($match){
return '<a href="'.get_subpage_url($match[1], $match[2]).'">'.$match[3].'</a>';
}, $lang_string);
[LINK:functions:bankimport]Bankimport[/LINK]
'<a href="'.get_subpage_url('functions', 'bankimport').'">Bankimport</a>'
preg_replace_callback(): Compilation failed: unmatched parentheses at offset 12
答案 0 :(得分:1)
答案 1 :(得分:1)
我现在无法在此测试,但我认为你必须绕过LINK-Tags周围的括号:
$lang_string = preg_replace_callback('/\[LINK:([^:]+):([^:]+)\](.+)\[\/LINK\]/m', function($match){
return '<a href="'.get_subpage_url($match[1], $match[2]).'">'.$match[3].'</a>';
}, $lang_string);