Merge two functions that basically do the same thing

请求翻译

I'm currently using two functions to delete from each folder after 1 minute but as they basically do the same thing (just different folders called). I was wondering if they could be merged into one?

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);
          }
       }
    }

4个回答