我在XAMPP文件夾結構刪除文件夾及其內容年長超過2天PHP
Deletefiles
--Uploads
--Test1
--Test2
--index.php
的index.php我寫腳本來刪除上傳如測試1和測試2
$foldername = array('test1','test2');
function recursiveRemove($dir) {
$structure = glob(rtrim($dir, "/").'/*');
if (is_array($structure)) {
foreach($structure as $file) {
if (is_dir($file)) recursiveRemove($file);
elseif (is_file($file)) unlink($file);
}
}
rmdir($dir);
}
foreach($foldername as $fname){
recursiveRemove("uploads/".$fname."/");
}
所有文件夾及其內容
其工作正常。但我想只刪除大於2天的文件夾。如何更改我的腳本。
通過檢查文件日期 –
我知道dagon.but我們如何能夠調用的文件recursiveremove功能僅超過2天以上。如果不是....年長 –
看filemtime()和unlink文件http://php.net/manual/en/function.filemtime.php – Tom