glob
Find file paths that match patterns
glob()
function returns the file name or directory that matches the specified pattern.
This function returns an array containing matching files/directories. If an error occurs, return false.
<?php print_r ( glob ( "*.txt" ) ) ; ?>
The output is similar:
Array ( [0] => target.txt [1] => source.txt [2] => test.txt [3] => test2.txt )
<?php print_r ( glob ( "*.*" ) ) ; ?>
The output is similar:
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 )
glob ( pattern , flags )
parameter | describe |
---|---|
file | Required. Specify the search mode. |
size |
Optional. Special settings are specified.
Note: GLOB_ERR was added by PHP 5.1. |