Skip to content

Instantly share code, notes, and snippets.

@sokil
Last active August 29, 2015 14:06
Show Gist options
  • Save sokil/9d150afc2c05f34f7523 to your computer and use it in GitHub Desktop.
Save sokil/9d150afc2c05f34f7523 to your computer and use it in GitHub Desktop.
<?php
function dropDirectory($path) {
// drop included files and directories
foreach(new \DirectoryIterator($path) as $file) {
if($file->isDot()) {
continue;
}
// drop dir
if($file->isDir()) {
dropDirectory($file->getPathname());
rmdir($file->getPathname());
// drop file
} else {
unlink($file->getPathname());
}
}
// drop dir itself
rmdir($file->getPathname());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment