我目前正在使用两个函数在 1 分钟后从每个文件夹中删除,但因为它们基本上做同样的事情(只是调用了不同的文件夹)。我想知道它们是否可以合并为一个?
function DeleteFromFolder1() {
$captchaFolder = 'folder1/';
$fileTypes = '*.jpg';
$expire_time = 1;
foreach(glob($captchaFolder . $fileTypes) as $Filename) {
$FileCreationTime = filectime($Filename);
$FileAge = time() - $FileCreationTime;
if($FileAge > ($expire_time * 60))
{
unlink($Filename);
}
}
}
function DeleteFromFolder2() {
$captchaFolder = 'folder2/';
$fileTypes = '*.jpg';
$expire_time = 1;
foreach(glob($captchaFolder . $fileTypes) as $Filename) {
$FileCreationTime = filectime($Filename);
$FileAge = time() - $FileCreationTime;
if($FileAge > ($expire_time * 60))
{
to ($Filename);
}
}
}