复制代码 代码如下:
function compare($ph1,$ph2){
$ret = '';
$_f1Arr = explode("/",$ph1);
$_f2Arr = explode("/",$ph2);
$f1 = array_pop($_f1Arr);
$f2 = array_pop($_f2Arr);
for($i=0;$i if($_f1Arr[$i] !== $_f2Arr[$i])
break;
}
for($j= $i-1;$j $ret .= "../";
}
for($i-1;$i $ret .= $_f2Arr[$i].'/';
}
return $ret.$f2;
}
$file1 = "aaa/ddd/ccc/ddd/test/a.js";
$file2 = "aaa/ddd/ccc/ddd/test/b.js";
echo compare($file1,$file2);
?>
B对于A的相对路径。。。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn