note 57289 deleted from function.realpath by mazzanet
| From: | mazzanet@php.net | Date: | Mon, 03 Oct 2005 08:31:02 +0000 |
| Subject: | note 57289 deleted from function.realpath by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96228@lists.php.net to get a copy of this message | ||
Note Submitter: Virtual DarKness
----
Here is mine:
<?php
function cleanUrlPath($path) {
$path=str_replace("/./", "/", $path);
$path_arr=array_reverse(explode("/", $path));
$skip=0;
$clean_arr=array();
foreach($path_arr as $cf) {
if ($cf == "..")
$skip++;
else {
if ($skip > 0)
$skip--;
else
$clean_arr[]=$cf;
}
}
$res=implode("/", array_reverse($clean_arr));
return $res;
}
?>
note that at this time doesn't check for "//" in the string or http[s]:// at the
beginning of the string..
bye,
Giovanni.