欢迎访问 水平网, 今天是:2010年09月09日 [订阅本站] [用户注册/登录] [收藏本站]
首     页 技术文章 注 册 码 代码仓库 资源下载 技术讨论 实用工具 站内搜索 联系我们
■ 站内搜索
■ 推荐
■ 热点
■ 相关
■ 当前位置:首页 >> 代码仓库 >> PHP相关 >> 代码内容

相对路径转化成绝对路径

■ 以下是代码:复制代码】【保存代码
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;
}
TAGS:路径
■ 发表评论
您的称呼:
联系方式:
验 证 码 : 看不清楚?点击刷新验证码 看不清楚?点击图片刷新验证码
■ 最新评论显示所有评论