Created
December 17, 2018 07:34
-
-
Save koriym/a7b64aabc90b689103f4228586c93e54 to your computer and use it in GitHub Desktop.
ディレクトリ内のファイルの消去 ref: https://qiita.com/koriym/items/b7e60f621b9a0a868d7f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array_map('unlink', glob("path/to/dir/*.php")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (new \RecursiveDirectoryIterator('path/to/dir', \FilesystemIterator::SKIP_DOTS) as $file) { | |
unlink($file); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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