Created
June 10, 2014 15:27
-
-
Save jgdoncel/7f3ff7db6e76ccdf8c57 to your computer and use it in GitHub Desktop.
Eliminar directorio (recursivo)
From http://stackoverflow.com/questions/1407338/a-recursive-remove-directory-function-for-php
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
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