Freelancer Martin Zeller

php asp.net java c# .net c++ xml xhtml seo magento zend framework dotnetnuke tomcat iis sql server mysql oracle typo3 coremedia

PHP – Delete files by pattern

Tags:

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 *.*

Tags:

Leave a Reply

© 2009 Freelancer Martin Zeller. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.