Skip to content

Instantly share code, notes, and snippets.

@wp-kitten
Forked from liconti/rrmdir.php
Created September 29, 2018 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wp-kitten/65eaa8e4d84c5235168239d233aab218 to your computer and use it in GitHub Desktop.
Save wp-kitten/65eaa8e4d84c5235168239d233aab218 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);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment