Home >php教程 >php手册 >php求两个目录的相对路径示例

php求两个目录的相对路径示例

WBOY
WBOYOriginal
2016-06-13 09:39:591051browse

 这篇文章主要介绍了php求两个目录的相对路径示例(php获取相对路径),需要的朋友可以参考下

求两个目录的相对路径,不限制路径深度    代码如下: /**  * 输出$b相对于$a的相对路径($a)  * 不限限制路径深度,没有做什么优化,只是实现功能  */ function getPath($a, $b) {  $aArr = explode('/', dirname($a));  $bArr = explode('/', dirname($b));    $aLen = count($aArr);  $bLen = count($bArr);    $len = max($aLen, $bLen);    $k = 0;    for($i = 0; $i
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn