Skip to content

Instantly share code, notes, and snippets.

@chaoswey
Last active July 22, 2019 01:49
Show Gist options
  • Save chaoswey/374798adfb4d40b49554fb1217275d45 to your computer and use it in GitHub Desktop.
Save chaoswey/374798adfb4d40b49554fb1217275d45 to your computer and use it in GitHub Desktop.
php All File And Folder In Folder
<?php
$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());
}
}
rmdir($dir);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment