function realPath($path) {
$path = ereg_replace('/+', '/', $path);
$patharray = explode('/', $path);
$path = '';
$count = count($patharray); //We have multiple count($patharray) so a minor bit faster.
for ($i=0; $i<$count; $i++) {
if ( $patharray[$i] == '.' || $patharray[$i]== '..' || ( (($i+1) < $count) && ($patharray[$i+1]== '..')) ) {
//If the current pos is a . ignore, if pos+1 == .. ignore, lastly if current = .. ignore.
} else {
$path .= $patharray[$i].'/';
}
}
//Trim trailing slash
if (!empty($path)) $path = substr($path, 0, -1);
return $path;
}
$path = ereg_replace('/+', '/', $path);
$patharray = explode('/', $path);
$path = '';
$count = count($patharray); //We have multiple count($patharray) so a minor bit faster.
for ($i=0; $i<$count; $i++) {
if ( $patharray[$i] == '.' || $patharray[$i]== '..' || ( (($i+1) < $count) && ($patharray[$i+1]== '..')) ) {
//If the current pos is a . ignore, if pos+1 == .. ignore, lastly if current = .. ignore.
} else {
$path .= $patharray[$i].'/';
}
}
//Trim trailing slash
if (!empty($path)) $path = substr($path, 0, -1);
return $path;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货