求两个相对路径

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;
}

原文地址:https://www.cnblogs.com/wxc1/p/6114438.html