Created
April 20, 2012 06:26
-
-
Save liconti/2426567 to your computer and use it in GitHub Desktop.
PHP recursive rmdir
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 rrmdir($path){ | |
if (is_dir($path)) { | |
array_map( "rrmdir", glob($path . DIRECTORY_SEPARATOR . '{,.[!.]}*', GLOB_BRACE) ); | |
@rmdir($path); | |
} | |
else { | |
@unlink($path); | |
} | |
} | |
?> |
Não se deve usar o @, mas sim tratar mesmo que seja trabalhoso.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This function does not recognize files whose name contains two or more leading dots. Here is a link to my fork which supports this edge case: https://gist.github.com/jmwebservices/986d9b975eb4deafcb5e2415665f8877