开发者

replace any link

开发者 https://www.devze.com 2023-01-05 12:18 出处:网络
I have a news script in PHP i need the script to replace any link which it will be included within the news (links to other websites which the original news will be there ) i need the link for the web

I have a news script in PHP i need the script to replace any link which it will be included within the news (links to other websites which the original news will be there ) i need the link for the website to b开发者_开发问答e replace with click here instead , all the links will be replaced every time with click here


$url="http://google.com";
$url=preg_replace('@(http?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">Click Here</a>', $url);
echo $url;//echoes <a href="http://google.com">Click Here</a>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号