note 88421 deleted from function.realpath by danbrown

From: Date: Fri, 23 Jan 2009 16:24:40 +0000
Subject: note 88421 deleted from function.realpath by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149700@lists.php.net to get a copy of this message
Note Submitter: Zhenya dot Morozov at gmail dot com Reason: 0 ---- There's a little bug in Isaac Z. Schlueter's function. If your path contains "0" (or any "false" string) directory name, the function removes that directory from the path. A little fix follows. <?php function resolve_href ($base, $href) { /* code omitted */ // resolve /../ // loop through all the parts, popping whenever there's a .., pushing otherwise. $parts = array(); foreach ( explode('/', preg_replace('~/+~', '/', $path)) as $part ) if ($part === "..") { array_pop($parts); } elseif ($part!="") { $parts[] = $part; } /* code omitted */ } ?>

« previous php.notes (#149700) next »