note 46930 added to function.rmdir
| From: | agotterer at email dot com | Date: | Thu, 28 Oct 2004 03:05:43 +0000 |
| Subject: | note 46930 added to function.rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79221@lists.php.net to get a copy of this message | ||
Heres a way to remove the directory, and all sub content.
function deldir($dir) {
$dh=opendir($dir);
while ($file=readdir($dh)) {
if($file!="." && $file!="..") {
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)) {
unlink($fullpath);
} else {
deldir($fullpath);
}
}
}
closedir($dh);
if(rmdir($dir)) {
return true;
} else {
return false;
}
}
----
Manual Page -- http://www.php.net/manual/en/function.rmdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46930
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46930&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46930&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46930&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46930&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46930&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46930&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46930&report=yes
Search -- http://master.php.net/manage/user-notes.php