-
-
Save hadifarnoud/5a047fda2338b42480cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteDirectory($dir) { | |
if (!file_exists($dir)) { | |
return true; | |
} | |
if (!is_dir($dir)) { | |
return unlink($dir); | |
} | |
foreach (scandir($dir) as $item) { | |
if ($item == '.' || $item == '..') { | |
continue; | |
} | |
if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) { | |
return false; | |
} | |
} | |
return rmdir($dir); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment