How do you auto delete all files under a sub directory after x-time (let say after 24 hours) - without using a cronjob command from server or pl. How can you do this just us
function deleteCachedData($hours=24) { $files = glob(ROOTDIR.DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'*.txt'); foreach($files as $file) { if(is_file($file) && (time() - filectime($file)) > $hours*3600) { unlink($file); } }
}