Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement