...

View Full Version : problem with last modified on file list



brothercake
01-28-2003, 11:27 AM
I'm using code like this



$dir_handle = opendir($filePath);

while ($file = readdir($dir_handle)) {
if(ereg("\.doc",$file)) {
$mod = getlastmod($file);
$fileAry[] = array($mod,$file);
}
}

closedir($dir_handle);



But the value returned in $mod is not the last modified date, it's today's date ..? Is that because reading the directory counts as "touching" the file, and if so what can I do?

Íkii
01-28-2003, 12:08 PM
It shouldn't do, though I 'spose if it is, it does.

Perhaps try

filemtime($file);

brothercake
01-28-2003, 02:48 PM
That just gave me a "no such file" error ... but it led me to try

$mod = filemtime($filePath.$file);

Which works, and so presumably means that the $file var doesn't refer to the file, but merely contains a string of its filename ...

Makes sense, but I didn't realise it was like. Ah well - thanks for the help :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum