d
Amit DhamuSoftware Engineer
 

Search Files Using glob()

1 minute read 00000 views

PHP's glob() function allows you to search for files matching a pattern. More examples of these can be found here. The results are returned as an array.

$directory = "./";

// Gets all PHP files
print_r(glob($directory."*.php"));

// Gets all PHP and TXT files
print_r(glob($directory."*.{txt,php}", GLOB_BRACE));