utils.php 542 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. class Utils {
  3. /**
  4. * Recursively remove a directory.
  5. *
  6. * @param string $directory
  7. * @return void
  8. */
  9. public static function rrmdir($directory)
  10. {
  11. if (is_dir($directory))
  12. {
  13. $objects = scandir($directory);
  14. foreach ($objects as $object)
  15. {
  16. if ($object != "." && $object != "..")
  17. {
  18. if (filetype($directory."/".$object) == "dir") static::rrmdir($directory."/".$object); else unlink($directory."/".$object);
  19. }
  20. }
  21. reset($objects);
  22. rmdir($directory);
  23. }
  24. }
  25. }