I want to delete all the files in the public_html directory of my domain by a single command. For this one of SO\'s questions had this answer:
Use something like this:
function delete_all($filename) {
// files listed in this array will not being deleted
$exceptions = array (
'file1',
'file2', ...
);
if(!in_array($filename, $exceptions)) {
unlink($filename);
}
}
// !!! attention !!! this will delete all files except those listed above
// from this folder. Make sure you know what you are doing
array_map('delete_all', glob("path/to/temp/*"));