PHP Function Pathinfo
The php function pathinfo allows developers to turn a filepath into an array which can be used to get the dirname, basename and extension. It is an important tool that makes handling file paths easier and simpler.
The PHP pathinfo() function is a built-in function that returns information about a file path in the form of an associative array or a string, depending on the value of its $options parameter. It is locale aware, meaning that in order for it to parse a file path correctly with multibyte characters, the matching locale must be set using the setlocale() function.
If the $options parameter is not present, an associative array containing dirname, basename and extension (if any) will be returned. If the basename of the file starts with a dot, then any character following the dot is interpreted as an extension and the final string will contain just the extension.
If the $options parameter is present, it specifies which part of the path to return; one of PATHINFO_DIRNAME, PATHINFO_BASENAME, PATHINFO_EXTENSION or PATHINFO_FILENAME. If not present, all available elements will be returned.