写出两个文件的相对路径

写入两个文件的相对路径 $b相对$a的绝对路径
$a = '/a/b/c/d/e.php';
$b = '/a/b/12/34/c.php';
function getRelativelyPath($b, $a){
	$b = explode('/', $b);
	$a = explode('/', $a);
	$c = array_diff($b,$a);
	$d = array_diff($a, $b);
	array_pop($d);
	$upPathArr = array_fill(0,count($d),'..');
	$pathArr   = array_merge($upPathArr, $c);
	return join('/',$pathArr);
}

你可能感兴趣的:(相对路径)