Try the dirname function
e.g
$path = "/etc/passwd";
$file = dirname ($path);
// $file is set to "/etc"
On Windows, both slash (/) and backslash () are used as path separator character. In other environments, it is the forward slash (/).
As an aside, the basename function returns the filename component of a path
e.g
$path = "/home/httpd/html/index.php3";
$file = basename ($path);
// $file is set to "index.php3"