Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public function recurse_remove($dir, $remove_parent = false){
  2. $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
  3. $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
  4. foreach($files as $file) {
  5. if ($file->isDir()){
  6. rmdir($file->getRealPath());
  7. } else {
  8. unlink($file->getRealPath());
  9. }
  10. }
  11. if($remove_parent == true){
  12. rmdir($dir);
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement