Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@koriym
Created December 17, 2018 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koriym/a7b64aabc90b689103f4228586c93e54 to your computer and use it in GitHub Desktop.
Save koriym/a7b64aabc90b689103f4228586c93e54 to your computer and use it in GitHub Desktop.
ディレクトリ内のファイルの消去 ref: https://qiita.com/koriym/items/b7e60f621b9a0a868d7f
array_map('unlink', glob("path/to/dir/*.php"));
foreach (new \RecursiveDirectoryIterator('path/to/dir', \FilesystemIterator::SKIP_DOTS) as $file) {
unlink($file);
}
foreach (new \RecursiveDirectoryIterator('path/to/dir', \FilesystemIterator::SKIP_DOTS) as $file) {
/* @var \SplFileInfo $file */
if (strpos($file->getFilename(), '.') === 0) {
continue; // 不可視ファイルは削除しない
}
unlink($file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment