note 44491 added to function.rmdir
| From: | walaces at uol dot com dot br | Date: | Sat, 07 Aug 2004 21:56:29 +0000 |
| Subject: | note 44491 added to function.rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74157@lists.php.net to get a copy of this message | ||
Another example about recursive delete....
<?php
function rm_recursivo($_arq) {
if(is_dir($_arq)) {
$_d = opendir($_arq);
while(($_f = readdir($_d))!==FALSE) {
if($_f!='.' && $_f!='..') {
if(rm_recursivo("$_arq/$_f")===FALSE)
return FALSE;
}
}
closedir($_d);
return rmdir($_arq);
}
else {
return unlink($_arq);
}
}
// Example
if(rm_recursivo("c:\\TEMP\\TEST")===TRUE) {
echo "OK";
}
else {
echo "ERROR";
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.rmdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44491
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44491&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44491&report=yes
Search -- http://master.php.net/manage/user-notes.php