I wonder, what's the easiest way to delete a directory with all its files in it?
I'm using rmdir(PATH . '/' . $value);
to delete a folder, however, if there are files inside of it, I simply can't delete it.
I wonder, what's the easiest way to delete a directory with all its files in it?
I'm using rmdir(PATH . '/' . $value);
to delete a folder, however, if there are files inside of it, I simply can't delete it.
You can try as follows:
If you are not sure, Given path is directory or file then you can use this function to delete path
Have your tryed out the obove code from php.net
Work for me fine
Delete all files in Folder
array_map('unlink', glob("$directory/*.*"));
Delete all .*-Files in Folder (without: "." and "..")
array_map('unlink', array_diff(glob("$directory/.*),array("$directory/.","$directory/..")))
Now delete the Folder itself
rmdir($directory)
I do not remember from where I copied this function, but it looks like it is not listed and it is working for me
Example for the Linux server:
exec('rm -f -r ' . $cache_folder . '/*');