I have a php file with the following script. However, the file must be in the SAME directory it is reading in order for the timestamp to work. If I put the script in another directory, then the timestamp portion of the script will return a blank. How do I fix this?? Thanx
<?php
$file_array = array();
$handle = opendir('/mydomain/www/files/');
while (false!=($file = readdir($handle))) {
if ($file != "." && $file != ".." && ereg(".xml",$file)) {
$file_array[$file] = filemtime($file); //STORING
}
}
closedir($handle);
arsort($file_array, SORT_NUMERIC); //sort file array based on timestamp in descending order.
$i = 0;
foreach ($file_array as $key => $value) {
if ($i < 20) {
print $key . " (timestamp: " . $value . ")<br>";
$i++;
}
}
?>