Extracts a function from the Gregarius. You can automatically convert a relative path in a Web page to an absolute path.
function Relative_to_absolute ($content, $feed _url) {
Preg_match ('/(HTTP|HTTPS|FTP): \/\//', $feed _url, $protocol);
$server _url = Preg_replace ("/(http|https|ftp|news): \/\//", "", $feed _url);
$server _url = preg_replace ("/\/.*/", "", $server _url);
if ($server _url = = ") {
return $content;
}
if (isset ($protocol [0])) {
$new _content = preg_replace ('/href= ' \//', ' href= '. $protocol [0]. $server _url. ' /', $content);
$new _content = preg_replace ('/src= ' \//', ' src= '. $protocol [0]. $server _url. ' /', $new _content);
} else {
$new _content = $content;
}
return $new _content;
}
?>
The above describes the path relative path to the absolute path, including the content of the path, I hope to be interested in PHP tutorial friends helpful.