If you want to delete files by pattern (e.g. “*.txt”) in a directory, you can do this with the php function glob!
$files = glob('/path/to/files/*.txt'); // finds all txt files in the directory /path/to/files/ foreach($files as $file) unlink($file);
With this method you can also delete all files of a directory – with pattern *.*
Comments 1
Schöner post:)