note 41957 deleted from function.realpath by aidan

From: Date: Sun, 29 Aug 2004 21:49:39 +0000
Subject: note 41957 deleted from function.realpath by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75602@lists.php.net to get a copy of this message
Note Submitter: D1g174LM4n14c ---- My way to resolve real path with free base path. <?php function resolve_path($base, $path) { $base = str_replace('\\', '/', $base); $path = str_replace('\\', '/', $path); if (substr($base, -1) == '/') $base = substr($base, 0, -1); $base = explode('/', $base); $path = explode('/', $path); // del unnecessary elements $path = array_diff($path, array('', '.')); while ($dir = array_shift($path)) { if ($dir == '..') { array_pop($base); continue; } $base[] = $dir; } return implode('/', $base).'/'; } ?>

« previous php.notes (#75602) next »