Definition :
The PHP glob() function returns an array of filenames or directories matching a specified pattern. The function returns an array containing the matched files/directories or an empty array if no match is found. It returns false on error.
glob(pattern, flags)
Parameter | Description |
---|---|
pattern | Required. Specifies the pattern to search for |
flags | Optional. Specifies special settings.
Possible values:
|
Given below example glob() function is used to get the filenames of all text files in the current working directory :
Output :
Array
(
[0] => demo.txt
[1] => file.txt
)