pathinfo

(PHP 4 >= 4.0.3, PHP 5)

pathinfo -- Returns information about a file path

Description

array pathinfo ( string path [, int options] )

pathinfo() returns an associative array containing information about path. The following array elements are returned: dirname, basename and extension.

You can specify which elements are returned with optional parameter options. It composes from PATHINFO_DIRNAME, PATHINFO_BASENAME and PATHINFO_EXTENSION. It defaults to return all elements.

Example 1. pathinfo() Example

<?php
$path_parts
= pathinfo('/www/htdocs/index.html');

echo
$path_parts['dirname'], "\n";
echo
$path_parts['basename'], "\n";
echo
$path_parts['extension'], "\n";
?>

Would produce:

/www/htdocs
index.html
html

Note: For information on retrieving the current path info, read the section on predefined reserved variables.

See also dirname(), basename(), parse_url() and realpath().

The Broward PHP Usergroup would like to thank the following sponsors.
  • South Florida Web Design

  • South Florida Maids

  • Miami Cleaning Service

  • Broward PHP Usergroup

  • Nationwide Real Estate Agent Directory

  • Fort Lauderdale Web Design

  • Real Estate Agent

  • Gourmet Flavored Coffee

  • convex optimization

  • convex optimization

  • Nationwide Bail Bonds Agent Directory

  • Fort Lauderdale Computer Repair

  • Broward County Computer Repair

  • dance music video

  • Miami Computer Repair