Created
October 9, 2012 13:42
-
-
Save lleitep3/3858884 to your computer and use it in GitHub Desktop.
delete some folder recursive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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