I use this method
array_map('unlink', glob("data/words/*.*"));
To delete all files Including all .txt
extension and It works well
But when there is a file named ..txt
is not deleted
I use this method
array_map('unlink', glob("data/words/*.*"));
To delete all files Including all .txt
extension and It works well
But when there is a file named ..txt
is not deleted
Please note that glob('*') ignores all 'hidden' files by default. This means it does not return files that start with a dot (e.g. .file).
If you want to match those files too, you can use "{,.}*" as the pattern with the GLOB_BRACE
flag.
<?php
// Search for all files that match .* or *
$files = glob('{,.}*', GLOB_BRACE);
?>
Specifically in your case, this should work.
array_map('unlink', glob("data/words/{,.}*",GLOB_BRACE));