Path Information
Split filename infos: pathinfo()
The function pathinfo()
is useful when you have a filename and you want to obtain:
dirname
: the directorybasename
: the filename with extensionextension
: the extensionfilename
: the filename without extension
$path_parts = pathinfo(__FILE__);print_r($path_parts);/*Array( [dirname] => /Users/user/project/BOOKS/50-drops-of-php/examples [basename] => 503_fil_pathinfo.php [extension] => php [filename] => 503_fil_pathinfo)*/
The input is a string with the filename, the result is an associative array with dirname
, basename
, extension
, filename
attributes.