更新时间:2023-02-23 10:41:04
$string = " fasfasd http://webarto.com fasfsafa";
echo preg_replace("#http://([\S]+?)#Uis", '<a rel="nofollow" href="http://\\1">\\1</a>', $string);
输出:
fasfasd <a rel="nofollow" href="http://webarto.com">webarto.com</a> fasfsafa