Skip to content

Instantly share code, notes, and snippets.

@liconti
Created April 20, 2012 06:26
Show Gist options
  • Save liconti/2426567 to your computer and use it in GitHub Desktop.
Save liconti/2426567 to your computer and use it in GitHub Desktop.
PHP recursive rmdir
<?php
function rrmdir($path){
if (is_dir($path)) {
array_map( "rrmdir", glob($path . DIRECTORY_SEPARATOR . '{,.[!.]}*', GLOB_BRACE) );
@rmdir($path);
}
else {
@unlink($path);
}
}
?>
@jmwebservices
Copy link

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

@ribafs
Copy link

ribafs commented Nov 4, 2019

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