Return file path information
php pathinfo() function syntax
Function: Return file path information in the form of an array.
Syntax: pathinfo(path,options)
Parameters:
Parameter | Description |
path | Required. Specifies the path to be checked. |
process_sections | Optional. Specifies the array elements to be returned. The default is all. Possible values: PATHINFO_DIRNAME - only dirname is returned. PATHINFO_BASENAME - only basename is returned. PATHINFO_EXTENSION - only extension is returned. |
Description: Returns an associative array containing path information. Includes the following array elements: [dirname], [basename], [extension]
php pathinfo() function example
<?php $file = "/phpstudy/WWW/index.php"; print_r(pathinfo($file)) ; ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
Array ( [dirname] => /phpstudy/WWW [basename] => index.php [extension] => php [filename] => index )