Quickly Get a List of Files in PHP with glob()
Oct 25, 2011 · 1 minute readCategory: php
This is post is now quite old and the the information it contains may be out of date or innacurate.
If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub
Need to get a list of files in a directory - try this:
$tools = glob('includes/tools/*');
var_dump($tools);
Want to delete all files matching a specific pattern, try this:
array_map('unlink', glob('export_feeds/my_feed_*'));
Theres lots more tricks you can do.
One word of warning though - with great power comes great responsibility!
I would advise against using any kind of user input with this function.