maybe something like this
untested use at your own risk
#directory to scan
$Directory = "some_dir"
#time in seconds
$time = "259200"
if ($files = opendir($Directory)){
while (false !== ($currentFile = readdir($files))){
#skip "." and ".."
if ($currentFile != "." && $currentFile != "..") {
#get current time (unix epoch)
$currentTime = date(U);
#get file times (remember, it's epoch)
$fileTime = date(filemtime("$Directory/$currentFile"));
#subtract to come up with the difference
$remainder = $currentTime - $fileTime;
if ($remainder > $time){
$cleanup = unlink("$Directory/$currentFile");
}//end if
}//end if
}//end while
}//end if