...

View Full Version : Resolved Delete old files function won't work



sonny
08-19-2012, 03:13 AM
Anyone know why this won't work?
I can't see anything wrong.


function DeleteOldFiles($path) {
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ((time()-filemtime()($path.$file) >= 2*24*60*60) // 2 days {
if (preg_match('/\.log$/i', $file)) {
unlink($path.$file);
}
}
}
}
}
DeleteOldFiles('./logs/');

AndrewGSW
08-19-2012, 05:16 AM
You've commented out a bracket { so the syntax is wrong. But you haven't correctly supplied the argument for filemtime():


if ((time()-filemtime($path.$file) >= 2*24*60*60) { // 2 days

sonny
08-19-2012, 06:22 AM
Thanks, I looked at that code, or at least I thought so, how the heck
I left out the path, and commented out my bracket, I think I need to
stop for the night before I really start screwing things up.

Thanks
Sonny



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum