Skip to content

Instantly share code, notes, and snippets.

@sercey
Created March 10, 2015 22:26
Show Gist options
  • Save sercey/14aa06481f80896d66fc to your computer and use it in GitHub Desktop.
Save sercey/14aa06481f80896d66fc to your computer and use it in GitHub Desktop.
Belirtilen dizindeki tüm dosya ve klasorleri siler
public function recurse_remove($dir, $remove_parent = false){
$it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
foreach($files as $file) {
if ($file->isDir()){
rmdir($file->getRealPath());
} else {
unlink($file->getRealPath());
}
}
if($remove_parent == true){
rmdir($dir);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment