Skip to content

Instantly share code, notes, and snippets.

@zemd
Created June 22, 2014 14:39
Show Gist options
  • Save zemd/4eb1969f1de30a4d098f to your computer and use it in GitHub Desktop.
Save zemd/4eb1969f1de30a4d098f to your computer and use it in GitHub Desktop.
recursive rmdir
<?php
$dirPath = __DIR__.'/../app/cache/dev';
if (file_exists($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