note 116013 deleted from function.unlink by cmb
| From: | cmb@php.net | Date: | Sun, 29 Dec 2019 11:34:40 +0000 |
| Subject: | note 116013 deleted from function.unlink by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213691@lists.php.net to get a copy of this message | ||
Note Submitter: softontherocks at gmail dot com
----
Here you have a function to delete a directory and subdirectories recursively:
function deleteDirectory($dir){
$result = false;
if ($handle = opendir("$dir")){
$result = true;
while ((($file=readdir($handle))!==false) && ($result)){
if ($file!='.' && $file!='..'){
if (is_dir("$dir/$file")){
$result = deleteDirectory("$dir/$file");
} else {
$result = unlink("$dir/$fich");
}
}
}
closedir($handle);
if ($result){
$result = rmdir($dir);
}
}
return $result;
}
The source is found in http://softontherocks.blogspot.com/2014/09/eliminar-un-directorio-completo-con-php.html