This article mainly introduces the content is about PHP glob () function, has a certain reference value, now share to everyone, the need for friends can refer to
PHP Glob () function
PHP Filesystem functions
Definition and usage
The Glob () function returns the file name or directory that matches the specified pattern.
The function returns an array that contains a matching file/directory. Returns False if an error occurs.
Grammar
Glob (Pattern,flags)
Parameters |
Description |
Pattern |
Necessary. Specifies the retrieval mode. |
flags |
optional. Specify a special setting.
-
Glob_mark-Add a slash to each returned item /p>
-
Glob_nosort-Returns (not sorted) according to the original order in which the files appear in the directory
-
Glob_nocheck-Returns the mode for search if no file matches li>
Glob_noescape-Backslash does not escape metacharacters
-
Glob_brace-expands {a,b,c} to match ' A ', ' B ' or ' C '
-
Glob_onlyd IR-Returns only directory entries that match the pattern
-
Glob_err-Stop and read error messages (such as unreadable directories), ignoring all errors by default
Note: Glob_err is added in PHP 5.1. |
Example
Example 1
<?phpprint_r (Glob ("*.txt"));? >
The output is similar to:
Array ([0] = target.txt[1] = source.txt[2] = test.txt[3] = test2.txt)
Example 2
<?phpprint_r (Glob ("* *"));? >
The output is similar to:
array ([0] = contacts.csv[1] [default.php[2] = target.txt[3] + source.txt[4] = tem1.tmp[5] = Test . htm[6] [test.ini[7] = test.php[8] = test.txt[9] = test2.txt)