function compare($ph1,$ph2){
$ret = \'\';
$_f1Arr = explode(\"/\",$ph1);
$_f2Arr = explode(\"/\",$ph2);
$f1 = array_pop($_f1Arr);
$f2 = array_pop($_f2Arr);
for($i=0;$i<count($_f1Arr);$i++){
if($_f1Arr[$i] !== $_f2Arr[$i])
break;
}
for($j= $i-1;$j<count($_f1Arr);$j++){
$ret .= \"../\";
}
for($i-1;$i<count($_f2Arr);$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的相对路径。。。
本文地址:https://www.stayed.cn/item/24233
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我