Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pathinfo(3) [php man page]

PATHINFO(3)								 1							       PATHINFO(3)

pathinfo - Returns information about a file path

SYNOPSIS
mixed pathinfo (string $path, [int $options = PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME]) DESCRIPTION
pathinfo(3) returns information about $path: either an associative array or a string, depending on $options. PARAMETERS
o $path - The path to be parsed. o $options - If present, specifies a specific element to be returned; one of PATHINFO_DIRNAME, PATHINFO_BASENAME, PATHINFO_EXTENSION or PATHINFO_FILENAME. If $options is not specified, returns all available elements. RETURN VALUES
If the $options parameter is not passed, an associative array containing the following elements is returned: dirname, basename, extension (if any), and filename. Note If the $path has more than one extension, PATHINFO_EXTENSION returns only the last one and PATHINFO_FILENAME only strips the last one. (see first example below). Note If the $path does not have an extension, no extension element will be returned (see second example below). If $options is present, returns a string containing the requested element. CHANGELOG
+--------+--------------------------------------------+ |Version | | | | | | | Description | | | | +--------+--------------------------------------------+ | 5.2.0 | | | | | | | The PATHINFO_FILENAME constant was added. | | | | +--------+--------------------------------------------+ EXAMPLES
Example #1 pathinfo(3) Example <?php $path_parts = pathinfo('/www/htdocs/inc/lib.inc.php'); echo $path_parts['dirname'], " "; echo $path_parts['basename'], " "; echo $path_parts['extension'], " "; echo $path_parts['filename'], " "; // since PHP 5.2.0 ?> The above example will output: /www/htdocs/inc lib.inc.php php lib.inc Example #2 pathinfo(3) example showing difference between null and no extension <?php $path_parts = pathinfo('/path/emptyextension.'); var_dump($path_parts['extension']); $path_parts = pathinfo('/path/noextension'); var_dump($path_parts['extension']); ?> The above example will output something similar to: string(0) "" Notice: Undefined index: extension in test.php on line 6 NULL NOTES
Note For information on retrieving the current path info, read the section on predefined reserved variables. Note pathinfo(3) is locale aware, so for it to parse a path containing multibyte characters correctly, the matching locale must be set using the setlocale(3) function. SEE ALSO
dirname(3), basename(3), parse_url(3), realpath(3). PHP Documentation Group PATHINFO(3)

Check Out this Related Man Page

GET_META_TAGS(3)							 1							  GET_META_TAGS(3)

get_meta_tags - Extracts all meta tag content attributes from a file and returns an array

SYNOPSIS
array get_meta_tags (string $filename, [bool $use_include_path = false]) DESCRIPTION
Opens $filename and parses it line by line for <meta> tags in the file. The parsing stops at </head>. PARAMETERS
o $filename - The path to the HTML file, as a string. This can be a local file or an URL. Example #1 What get_meta_tags(3) parses <meta name="author" content="name"> <meta name="keywords" content="php documentation"> <meta name="DESCRIPTION" content="a php manual"> <meta name="geo.position" content="49.33;-86.59"> </head> <!-- parsing stops here --> (pay attention to line endings - PHP uses a native function to parse the input, so a Mac file won't work on Unix). o $use_include_path - Setting $use_include_path to TRUE will result in PHP trying to open the file along the standard include path as per the include_path directive. This is used for local files, not URLs. RETURN VALUES
Returns an array with all the parsed meta tags. The value of the name property becomes the key, the value of the content property becomes the value of the returned array, so you can eas- ily use standard array functions to traverse it or access single values. Special characters in the value of the name property are substi- tuted with '_', the rest is converted to lower case. If two meta tags have the same name, only the last one is returned. EXAMPLES
Example #2 What get_meta_tags(3) returns <?php // Assuming the above tags are at www.example.com $tags = get_meta_tags('http://www.example.com/'); // Notice how the keys are all lowercase now, and // how . was replaced by _ in the key. echo $tags['author']; // name echo $tags['keywords']; // php documentation echo $tags['description']; // a php manual echo $tags['geo_position']; // 49.33;-86.59 ?> NOTES
Note Only meta tags with name attributes will be parsed. Quotes are not required. SEE ALSO
htmlentities(3), urlencode(3). PHP Documentation Group GET_META_TAGS(3)
Man Page