大佬教程收集整理的这篇文章主要介绍了PHP – 添加链接到字符串中的URL,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
function process@R_696_10495@ng($s) { // check if there is a link if(preg_match("/http:\/\//",$s)) { print preg_match("/http:\/\//",$s); $startUrl = @R_696_10495@pos($s,"http://"); // if the link is in between text if(@R_696_10495@pos($s," ",$startUrl)){ $endUrl = @R_696_10495@pos($s,$startUrl); } // if link is at the end of @R_696_10495@ng else {$endUrl = strlen($s);} $beforeUrl = substr($s,$startUrl); $url = substr($s,$startUrl,$endUrl-$startUrl); $afterUrl = substr($s,$endUrl); $new@R_696_10495@ng = $beforeUrl."<a href=\"$url\">".$url."</a>".$afterUrl; return $new@R_696_10495@ng; } return $s; }
function process@R_696_10495@ng($s) { return preg_replace('/https?:\/\/[\w\-\.!~#?&=+\*\'"(),\/]+/','<a href="$0">$0</a>',$s); }
以上是大佬教程为你收集整理的PHP – 添加链接到字符串中的URL全部内容,希望文章能够帮你解决PHP – 添加链接到字符串中的URL所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。