PHP » I/O » dirname()

Syntax:
string dirname(string filepath)
filepath
A filename.

Extracts the directory name from a file path.

dirname() is similar to basename(), but returns the directory instead.

Examples

Code:
<?php

$filename = "/var/tmp/phptest.log";
print dirname($filename);

?>
Output:
/var/tmp
Explanation:

Prints the directory part of a file path.

See Also: