【发布时间】:2012-10-29 19:45:34
【问题描述】:
我正在尝试替换一个 href 并且我有以下代码:<a href="http://www.mysite.com" target="_blank">My site</a>
这样:
$textarea_content = '<a href="http://www.mysite.com" target="_blank">My site</a>';
$patterns = array(
"/<a href=/",
"/target*\=*\'*\_blank*\'*\>/",
"/<*\/a>/"
);
$replacements = array(
"[url=",
"]",
"[/url]"
);
$textarea_content = preg_replace($patterns,$replacements, $textarea_content);
我需要把链接标签转换成这个结构:
[url='http://www.mysite.com']My site[/url]
问题是输出类似于:<a href="" http:="" www.mysite.com''="" target="_blank">My site</a>
我做错了什么?感谢您的帮助!
【问题讨论】: