the code down below delete all files inside a folder called " Images ". No complains everything works as it should, but is there a way to only delete the file which was created an hour ago or more then hour ago instead? Please show me how, I'm trying to learn by doing, please. Try to re-use the same code down below for better understanding and also to help users PHP programmer around the world
<?php
define('PATH', 'Images/');
function destroy($dir) {
$mydir = opendir($dir);
while(false !== ($file = readdir($mydir))) {
if($file != "." && $file != "..") {
chmod($dir.$file, 0777);
if(is_dir($dir.$file)) {
chdir('.');
destroy($dir.$file.'/');
rmdir($dir.$file) or DIE("couldn't delete $dir$file<br />");
}
else
unlink($dir.$file) or DIE("couldn't delete $dir$file<br />");
}
}
closedir($mydir);
}
destroy(PATH);
echo 'all done.';