The pathinfo() function returns information about the file path in the form of an array.
The returned array elements are as follows:
[dirname]: directory path
[basename]: file name
[extension]: file suffix name
[filename]: file name without suffix
pathinfo(path,options)
parameter | describe |
---|---|
path | Required. Specifies the path to be checked. |
options | Optional. Specifies the array elements to be returned. The default is all. Possible values: PATHINFO_DIRNAME - returns only dirname PATHINFO_BASENAME - only returns basename PATHINFO_EXTENSION - only extensions are returned PATHINFO_FILENAME - only returns filename |
Note: If not all elements are requested, the pathinfo() function returns a string.
The above code will output:
Array( [dirname] => /testweb [basename] => test.txt [extension] => txt [filename] => test)
The above code will output:
test.txt