您好,欢迎访问一九零五行业门户网

根据当前页面url进行地址补全(采集用)

根据当前页面url进行地址补全(采集用)
function formaturl($url, $str){
    if (is_array($str)) {
        $return = array();
        foreach ($str as $href) {
            $return[] = formaturl($url, $href);
        }
        return $return;
    } else {
        if (stripos($str, 'http://')===0 || stripos($str, 'ftp://')===0) {
            return $str;
        }
        $str = str_replace('\\', '/', $str);
        $parseurl = parse_url(dirname($url).'/');
        $scheme = isset($parseurl['scheme']) ? $parseurl['scheme'] : 'http';
        $host = $parseurl['host'];
        $path = isset($parseurl['path']) ? $parseurl['path'] : '';
        $port = isset($parseurl['port']) ? $parseurl['port'] : '';
if (strpos($str, '/')===0) {
            return $scheme.'://'.$host.$str;
        } else {
            $part = explode('/', $path);
            array_shift($part);
            $count = substr_count($str, '../');
            if ($count>0) {
                for ($i=0; $i                    array_pop($part);
                }
            }
            $path = implode('/', $part);
            $str = str_replace(array('../','./'), '', $str);
            $path = $path=='' ? '/' : '/'.trim($path,'/').'/';
            return $scheme.'://'.$host.$path.$str;
        }        
    }
}
ad:真正免费,域名+虚机+企业邮箱=0元
其它类似信息

推荐信息