dosya tarihleri dizi içinde değil while içinde, min() ile yapmaya kalktım ama çuvalladım:
Amaç: bir dizindeki dosya sayısı x'e ulaşınca en eski dosyayı bulup silmek
$dir = './files/';
$files = scandir($dir); // php5 only
$count = count($files);
//echo $count;
$i = 0;
while ( $i < $count)
{
if ($files[$i] != "." && $files[$i] != ".." && $files[$i] != "index.html" && $files[$i] != "index.htm")
{
$file_num = ($count - 3);
$last_modified = filemtime($path . $files[$i]);
//echo "$files[$i] - $last_modified<br />";
if ($file_num > 3)
{
$delete_files[$i] = $last_modified;
//echo $delete_files[$i] . '<br />';
echo min($delete_files[$i]);
}
}
$i++;
}