|
Posted by Rik on 07/18/07 17:26
On Wed, 18 Jul 2007 18:42:47 +0200, laredotornado@zipmail.com =
<laredotornado@zipmail.com> wrote:
> 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 =3D '/path/to/directory';
$prefix =3D 'foo';
chdir($dir);
$matches =3D glob($prefix.'*',GLOB_MARK);
if(is_array($matches) && !empty($matches)){
foreach($matches as $match){
if(is_file($dir.$match) unlink($dir.$match);
}
}
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|