Name
glob
Synopsis
globarray(stringpattern
[, intflags
])
Returns a list of filenames matching the shell wildcard pattern
given in pattern
. The following characters
and sequences make matches:
| Matches any number of
any character (equivalent to the regex pattern |
| Matches any one
character (equivalent to the regex pattern |
For example, to process every JPEG file in a particular directory, you might write:
foreach
(
glob
(
"/tmp/images/*.jpg"
)
as
$filename
)
{
// do something with $filename
}
The flags
value is a bitwise OR of
any of the following values:
| Adds a slash to each item returned. |
| Returns files in the same order as found in the directory itself. If this is not specified, the names are sorted by ASCII value. |
| If no files matching pattern are found, pattern is returned. |
| Treat backslashes in pattern as backslashes, rather than as the start of an escape sequence. |
| In addition to the
normal matches, strings in the form |
| Returns only directories matching pattern. |
| Stop on read errors. |
Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.