Created
March 9, 2011 17:42
-
-
Save davidrautert/862624 to your computer and use it in GitHub Desktop.
Scan through a given directory, removing empty directories
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
function removeEmptySubFolders($path) { | |
$empty = true; | |
foreach (glob($path.DIRECTORY_SEPARATOR."*") as $file) { | |
$empty &= is_dir($file) && RemoveEmptySubFolders($file); | |
} | |
return $empty && rmdir($path); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment