Definition and Usage
定义和用法
The glob() function returns an array of filenames or directories matching a specified pattern.
glob()函数的作用是:以数组的形式返回与指定模式相匹配的文件名或目录。
This function returns an array of files/directories, or FALSE on failure.
如果函数执行成功,将以数组的形式返回文件名或目录;如果执行失败,将返回False。
Syntax
语法
glob(pattern,flags) |
Parameter参数 | Description描述 |
---|---|
pattern | Required. Specifies the pattern to search for 必要参数。指定搜索的样式 |
flags | Optional. Specifies special settings. 可选参数。指定详细的属性设置。 Possible values:
|
Example 1
案例1
<?phpprint_r(glob("*.txt"));?> |
The output of the code above could be:
上述代码将输出下面的结果:
Array([0] => target.txt[1] => source.txt[2] => test.txt[3] => test2.txt) |
Example 2
案例2
<?phpprint_r(glob("*.*"));?> |
The output of the code above could be:
上述代码将输出下面的结果:
Array([0] => contacts.csv[1] => default.php[2] => target.txt[3] => source.txt[4] => tem1.tmp[5] => test.