note 17788 deleted from function.rmdir by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 07 Aug 2004 23:49:10 +0000 |
| Subject: | note 17788 deleted from function.rmdir by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74176@lists.php.net to get a copy of this message | ||
Note Submitter: georg@spieleflut.de
----
Hello. If you want to delete a directory, try this. It erases even full directories:
<?php
function delete($file) {
chmod($file,0777);
if (is_dir($file)) {
$handle = opendir($file);
while($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") {
delete($file."/".$filename);
}
}
closedir($handle);
rmdir($file);
} else {
unlink($file);
}
}
delete("ordnername");
?>