note 41957 added to function.realpath

From: Date: Tue, 27 Apr 2004 18:07:13 +0000
Subject: note 41957 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-68896@lists.php.net to get a copy of this message
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).'/'; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.realpath.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41957 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41957&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41957&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68896) next »