Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public function deleteFolder($dir){
  2. if(file_exists($dir)){
  3. $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
  4. $files = new RecursiveIteratorIterator($it,
  5. RecursiveIteratorIterator::CHILD_FIRST);
  6. foreach($files as $file) {
  7. if ($file->isDir()){
  8. rmdir($file->getRealPath());
  9. } else {
  10. unlink($file->getRealPath());
  11. }
  12. }
  13. rmdir($dir);
  14. }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement