Get the directory name and filename from a full path name with PHP
It’s easy to get the filename and directory name components of a full path name with PHP using the dirname(), basename() and pathinfo() functions. The latter also contains the filename extension.