求两个相对路径

function getPath($path1,$path2){
$a=explode("/",$path1);
$b=explode("/",$path2);
$count=0;
$num=min(count($a),count($b));
for($i=0;$i<$num;$i++){
if($a[$i]!=$b[$i]){
unset($a[$i]);
$count++;
}

}
$c=str_repeat("../",$count).implode('/',$a);
return $c;
}

posted @ 2016-11-29 17:21  未解  阅读(89)  评论(0编辑  收藏  举报