Last active
January 5, 2018 15:11
-
-
Save toledorobia/0308c77c961cc6d48b3d to your computer and use it in GitHub Desktop.
PHP - Delete dirs recursively
This file contains hidden or 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
<?php | |
function rmdir_recursive($dir) { | |
foreach(scandir($dir) as $file) { | |
if ('.' === $file || '..' === $file) continue; | |
if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file"); | |
else unlink("$dir/$file"); | |
} | |
rmdir($dir); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment