Last active
February 21, 2022 03:55
-
-
Save Sharifur/b3219987b9f219642e3c058e1b6dcdca to your computer and use it in GitHub Desktop.
delete all folder with file in php
This file contains hidden or 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 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