Today should be the boss's needs, will not be our page to modify a link, with js+iframe should also be able to achieve, but I want to try the PHP implementation method.
First you have to download someone else's page into your PHP, the implementation method can be used curl, file, here is a good article written http://www.11jn.com/phpbb/viewtopic.php?f=31&t= 1390, there is not much to say.
Then just use regular expression to find your link, because it is a specific link, directly write, such as Baidu (http\:\/\/www.baidu.com)
Here is the main function preg_replace ()
Mixed preg_replace (mixed $pattern, mixed $replacement, mixed $subject int $limit =1
int & $count]])
The replacement of the regular expression (to be replaced) needs to match the substituted object Optionally, specify the number of replacements, and if the limit is omitted or the value is-1, all occurrences will be replaced
To replace an instance of:
To replace the www.baidu.com with www.google.com.
$content= ' http://www.baidu.com '; $replace=preg_replace("(http\:\/\/www.baidu.com)", "http://www.google.com",$content ); Echo $replace;
Second instance of substitution:
Replace two multiple fields in one paragraph, replace www.baidu.com with www.google.com, and Windows replaces Linux
$content = "http://www.baidu.com on Windows.";
$str 1=array ("(http\:\/\/www.baidu.com)", "(Windows)");
$str 2=array ("http://www.google.com", "Linux");
$replace =preg_replace ($str 1, $str 2, $content);
Echo $replace;