Menu Riverview Church

GLOB

Find pathnames matching a pattern

SYNTAX

glob ( string $pattern [, int $flags = 0 ] ) : array

PARAMETERS

pattern

The pattern. No tilde expansion or parameter substitution is done. Special characters:

* Matches zero or more characters.
? Matches exactly one character (any character).
[...] Matches one character from a group of characters. If the first character is !, matches any character not in the group.
\ Escapes the following character, except when the GLOB_NOESCAPE flag is used.
flags

Valid flags:

GLOB_MARK Adds a slash to each directory returned
GLOB_NOSORT Return files as they appear in the directory (no sorting). When this flag is not used, the pathnames are sorted alphabetically
GLOB_NOCHECK Return the search pattern if no files matching it were found
GLOB_NOESCAPE Backslashes do not quote metacharacters
GLOB_BRACE Expands {a,b,c} to match 'a', 'b', or 'c'
GLOB_ONLYDIR Return only directory entries which match the pattern
GLOB_ERR Stop on read errors (like unreadable directories), by default errors are ignored.

RETURN

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.

EXAMPLES

PATTERN

Array
(
    [0] => /bin
    [1] => /dev
    [2] => /etc
    [3] => /home
    [4] => /lib
    [5] => /lib64
    [6] => /opt
    [7] => /proc
    [8] => /root
    [9] => /sbin
    [10] => /scripts
    [11] => /tmp
    [12] => /usr
    [13] => /var
)

FLAGS

Array
(
    [0] => /bin/
    [1] => /dev/
    [2] => /etc/
    [3] => /home/
    [4] => /lib/
    [5] => /lib64/
    [6] => /opt/
    [7] => /proc/
    [8] => /root/
    [9] => /sbin/
    [10] => /scripts/
    [11] => /tmp/
    [12] => /usr/
    [13] => /var/
)

PHP