note 60155 deleted from function.unlink by bjori
| From: | bjori@php.net | Date: | Wed, 12 Apr 2006 15:38:03 +0000 |
| Subject: | note 60155 deleted from function.unlink by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-107892@lists.php.net to get a copy of this message | ||
Note Submitter: stefano at takys dot it
----
A short but powerfull recursive function that works also if the dirs contain hidden files
function SureRemoveDir($dir) {
if(!$dh = @opendir($dir)) return;
while (($obj = readdir($dh))) {
if($obj=='.' || $obj=='..') continue;
if (!@unlink($dir.'/'.$obj)) {
SureRemoveDir($dir.'/'.$obj);
} else {
$file_deleted++;
}
}
if (@rmdir($dir)) $dir_deleted++;
}