On Wed, 18 Jul 2007 18:42:47 +0200,
la***********@zipmail.com
<la***********@zipmail.comwrote:
I'm using php 4.4.4. Given a particular directory, I want to delete
all the files that begin with the variable "$prefix". What is the
simplest way to do this?
$dir = '/path/to/directory';
$prefix = 'foo';
chdir($dir);
$matches = glob($prefix.'*',GLOB_MARK);
if(is_array($matches) && !empty($matches)){
foreach($matches as $match){
if(is_file($dir.$match) unlink($dir.$match);
}
}
--
Rik Wasmus