note 75409 deleted from function.realpath by danbrown
| From: | danbrown@php.net | Date: | Mon, 01 Jun 2009 13:01:23 +0000 |
| Subject: | note 75409 deleted from function.realpath by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156234@lists.php.net to get a copy of this message | ||
Note Submitter: adyballa at klingbim dot de
----
I have also a short solution.
But Im not sure, if it is performant.
Explode-Array solution seems to work very fast.
function buildRelativePath($path){
$oldP = "";
$newP = $path;
while($newP!=$oldP){
$oldP = $newP;
$newP = preg_replace("/([^\/]+\/)([^\/]+\/)(\.\.\/)/ms","$1",$newP);
}
return str_replace("//","",str_replace("./","",$newP));
}