[thelist] how to delete everything in a dir using php

mpember at phreaker.net mpember at phreaker.net
Wed Sep 25 23:26:01 CDT 2002


I have just the thing, I just happen to be at work at the moment and won't be back home for about 5 hours.  Here's a quick snippet I found that does basically the same thing.  If it doesn't work, send me an email off list and I'll dig out my code from home.

If you put it into a function, then you just call is recursively using each of the subdirectories.

<?phpsource>

$path = ".";
$dir_handle = @opendir($path) or die("Unable to open $path");
while ($file = readdir($dir_handle)) unlink($file);
closedir($dir_handle);

<phpsource?>
----
Michael Pemberton
mpember at phreaker.net

-- Original Message --
From: Dunstan Orchard <dunstan at 1976design.com>
To: evolt list <thelist at lists.evolt.org>
Send: 2002-09-26
Subject: [thelist] how to delete everything in a dir using php

Anyone know a 'select all' command? Or a nice loop...








More information about the thelist mailing list