I'm trying to delete cookie files with the unlink()
function and it's not working properly
I tried this code (found on php.net)
<?php array_map('unlink', glob("some/dir/*.txt")); ?>
But it do not delete the last created file...
There are any number of reasons your code may be failing on one file but not the others. It doesn't appear to be a logic error, but the first thing I would do is try to rewrite this as a loop rather than using array_map()
.
Then I would check for an error after each call to unlink()
if it returns FALSE
: if (!(unlink($file)) print_r(error_get_last());
and see what the system tells you about what's going on.