Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

glob(3) [php man page]

GLOB(3) 								 1								   GLOB(3)

glob - Find pathnames matching a pattern

SYNOPSIS
array glob (string $pattern, [int $flags]) DESCRIPTION
The glob(3) function searches for all the pathnames matching $pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells. PARAMETERS
o $pattern - The pattern. No tilde expansion or parameter substitution is done. o $flags - Valid flags: o GLOB_MARK - Adds a slash to each directory returned o GLOB_NOSORT - Return files as they appear in the directory (no sorting). When this flag is not used, the pathnames are sorted alphabetically o GLOB_NOCHECK - Return the search pattern if no files matching it were found o GLOB_NOESCAPE - Backslashes do not quote metacharacters o GLOB_BRACE - Expands {a,b,c} to match 'a', 'b', or 'c' o GLOB_ONLYDIR - Return only directory entries which match the pattern o GLOB_ERR - Stop on read errors (like unreadable directories), by default errors are ignored. RETURN VALUES
Returns an array containing the matched files/directories, an empty array if no file matched or FALSE on error. Note On some systems it is impossible to distinguish between empty match and an error. CHANGELOG
+--------+--------------------+ |Version | | | | | | | Description | | | | +--------+--------------------+ | 5.1.0 | | | | | | | | | | GLOB_ERR was added | | | | +--------+--------------------+ EXAMPLES
Example #1 Convenient way how glob(3) can replace opendir(3) and friends. <?php foreach (glob("*.txt") as $filename) { echo "$filename size " . filesize($filename) . " "; } ?> The above example will output something similar to: funclist.txt size 44686 funcsummary.txt size 267625 quickref.txt size 137820 NOTES
Note This function will not work on remote files as the file to be examined must be accessible via the server's filesystem. Note This function isn't available on some systems (e.g. old Sun OS). Note The GLOB_BRACE flag is not available on some non GNU systems, like Solaris. SEE ALSO
opendir(3), readdir(3), closedir(3), fnmatch(3). PHP Documentation Group GLOB(3)

Check Out this Related Man Page

glob.h(3HEAD)							      Headers							     glob.h(3HEAD)

NAME
glob.h, glob - pathname pattern-matching types SYNOPSIS
#include <glob.h> DESCRIPTION
The <glob.h> header defines the structures and symbolic constants used by the glob(3C). The structure type glob_t contains the following members: size_t gl_pathc /* count of paths matched by pattern */ char **gl_pathv /* pointer to a list of matched pathnames */ size_t gl_offs /* lots to reserve at the beginning of gl_pathv */ The following constants are provided as values for the flags argument: GLOB_APPEND Append generated pathnames to those previously obtained. GLOB_DOOFFS Specify how many null pointers to add to the beginning of gl_pathv. GLOB_ERR Cause glob() to return on error. GLOB_MARK Each pathname that is a directory that matches pattern has a slash appended. GLOB_NOCHECK If pattern does not match any pathname, then return a list consisting of only pattern. GLOB_NOESCAPE Disable backslash escaping. GLOB_NOSORT Do not sort the pathnames returned. The following constants are defined as error return values: GLOB_ABORTED The scan was stopped because GLOB_ERR was set or (*errfunc)() returned non-zero. GLOB_NOMATCH The pattern does not match any existing pathname, and GLOB_NOCHECK was not set in flags. GLOB_NOSPACE An attempt to allocate memory failed. GLOB_NOSYS Reserved. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
glob(3C), attributes(5), standards(5) SunOS 5.11 10 Sep 2004 glob.h(3HEAD)
Man Page