Skip to content

Instantly share code, notes, and snippets.

@lleitep3
Created October 9, 2012 13:42
Show Gist options
  • Save lleitep3/3858884 to your computer and use it in GitHub Desktop.
Save lleitep3/3858884 to your computer and use it in GitHub Desktop.
delete some folder recursive
<?php
function deleteDir($source)
{
if(!is_dir($source))
return false;
$it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source),
\RecursiveIteratorIterator::SELF_FIRST);
$it->next();
while($it->valid()){
if(!$it->isDot())
if($it->isFile())
unlink($it->getRealPath());
deleteDir($it->getRealPath());
$it->next();
}
rmdir($source);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment