Created
November 29, 2014 20:15
-
-
Save owzim/94bfe7b8822f1759d986 to your computer and use it in GitHub Desktop.
PHP: remove a dir recursively
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
| <?php | |
| class dir { | |
| public static function rmRecursive($dir) { | |
| $files = array_diff(scandir($dir), array('.','..')); | |
| foreach ($files as $file) { | |
| is_dir("$dir/$file") ? self::rmdirRecursive("$dir/$file") : unlink("$dir/$file"); | |
| } | |
| return rmdir($dir); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment