1
我已经写了一些代码,更改文本链接的链接,但它也改变了我的img
标签的src
属性像更改链接不改变HTML标签
<img src="some url"/><br>
http://google.com<br>
http://beezfeed.cu.ma<br>
这里我的代码改变它链接到
<img src="<a href="some url">some url</a>"/><br>
<a href="http://google.com">http://google.com</a><br>
<a href="http://beezfeed.cu.ma">http://beezfeed.cu.ma</a><br>
我希望它离开img标签,只用文本做这件事。这里是我的代码
function make_links_clickable($text){
return preg_replace('!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()[email protected]:%_+.~#? &;//=]+)!i', '<a href="$1">$1</a>', $text);
}
[转换纯文本的URL到PHP HTML链接]可能的复制(http://stackoverflow.com/问题/ 1960461 /转换纯文本的URL - 到 - HTML的超链接功能于PHP) – JYoThI