复制代码 代码如下:
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的相对路径。。。
http://www.bkjia.com/PHPjc/327723.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327723.htmlTechArticle复制代码 代码如下: function compare($ph1,$ph2){ $ret = ''; $_f1Arr = explode("/",$ph1); $_f2Arr = explode("/",$ph2); $f1 = array_pop($_f1Arr); $f2 = array_pop($_f2Arr); for...