Skip to content

Instantly share code, notes, and snippets.

@jgdoncel
Created June 10, 2014 15:27
Show Gist options
  • Save jgdoncel/7f3ff7db6e76ccdf8c57 to your computer and use it in GitHub Desktop.
Save jgdoncel/7f3ff7db6e76ccdf8c57 to your computer and use it in GitHub Desktop.
function deleteDirectoryRecursive($dirPath) {
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
$path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname());
}
rmdir($dirPath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment