tags:

views:

32

answers:

1

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 be replace with click here instead , all the links will be replaced every time with click here

A: 
$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"&gt;Click Here</a>
stormdrain
he just want to replace text between <a> and </a> not the link URL itself. He wanted to hide the url on display.
VOX
the code does just that. it will replace `http://google.com` (or whatever url) with `<a href="http://google.com">Click Here</a>`
stormdrain