php dirname function returns the directory name
dirname
(PHP 4, PHP 5)
dirname - Returns the component path of the directory name
Description
String dirname (String $path)
Given a string containing the path to a file, this function will return the name of the directory.
Parameters
Path
a path.
In Windows, both slash ( / ) and backslash ( ) serve as directory separators. In other environments, it is a forward slash ( / ).
Return value
The directory name returned. If there is no slash in the path, a dot ('.') is returned, showing the current directory. Otherwise, the string path is returned with any trailing/components removed.
Modify
Release Notes
5.0.0 dirname ( ) is now binary safe
4.0.3 dirname() is fixed for POSIX compliance.
Example
Example #1 dirname()