Skip to content

Instantly share code, notes, and snippets.

@Sharifur
Last active February 21, 2022 03:55
Show Gist options
  • Save Sharifur/b3219987b9f219642e3c058e1b6dcdca to your computer and use it in GitHub Desktop.
Save Sharifur/b3219987b9f219642e3c058e1b6dcdca to your computer and use it in GitHub Desktop.
delete all folder with file in php
function rmdir_recursive($dir) {
foreach(scandir($dir) as $file) {
if ('.' === $file || '..' === $file) continue;
if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file");
else unlink("$dir/$file");
}
rmdir($dir);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment