读书人

写出两个资料的相对路径

发布时间: 2012-08-25 10:06:20 作者: rapoo

写出两个文件的相对路径

写入两个文件的相对路径 $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);}

读书人网 >编程

热点推荐