Skip to content

Instantly share code, notes, and snippets.

@owzim
Created November 29, 2014 20:15
Show Gist options
  • Save owzim/94bfe7b8822f1759d986 to your computer and use it in GitHub Desktop.
Save owzim/94bfe7b8822f1759d986 to your computer and use it in GitHub Desktop.
PHP: remove a dir recursively
<?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