Skip to content

Instantly share code, notes, and snippets.

@davidrautert
Created March 9, 2011 17:42
Show Gist options
  • Save davidrautert/862624 to your computer and use it in GitHub Desktop.
Save davidrautert/862624 to your computer and use it in GitHub Desktop.
Scan through a given directory, removing empty directories
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