resimleri upload ediyorum, ama tarhie göre sıralanmasını istiyorum. filemtime uygulamam gerekiyor, ama nerede ve nasıl uygulayacağımı bilemiyorum. yardım lütfen. iki farklı kod var, ikisi de aynı işi görüyor.

1. Kod:

$scandir_array = scandir('files');

foreach($scandir_array as $folder){

if(is_dir('files/'.$folder) and $folder!='.' and $folder!='..'){

// define this key in the array, it will be blank, store categories as keys

$categories_array[$folder] = array();

// $total_photos_array[$folder] = 0;

$files_in_dir = scandir('files/'.$folder);

foreach($files_in_dir as $file){

if($file!='.' and $file!='..'){

// if file is not the category thumbnail (thumbnail.jpg) and not _thumb.jpg and not _small.jpg

if($file != "thumbnail.jpg" and substr($file, strlen($file)-10) != "_small.jpg" and substr($file, strlen($file)-10) != "_thumb.jpg"){

// $total_photos_array[$folder]++;

$base_file_name = substr($file, 0, strlen($file)-4);

// insert this file in the array of files

array_push($categories_array[$folder], $base_file_name);

}

}

}

}

}

krsort($categories_array);

2. Kod:

if ($handle = opendir('files')) {

while (false !== ($folder = readdir($handle))) {

if(is_dir('files/'.$folder) and $folder!='.' and $folder!='..'){

// define this key in the array, it will be blank, store categories as keys

$categories_array[$folder] = array();

// $total_photos_array[$folder] = 0;

$files_in_dir = scandir('files/'.$folder);

foreach($files_in_dir as $file){

// if file ends in _thumb.jpg

if(strpos($file, '_thumb.jpg') === strlen($file)-10){

// $total_photos_array[$folder]++;

$base_file_name = substr($file, 0, strlen($file)-10);

// insert this file in the array of files

array_push($categories_array[$folder], $base_file_name);

}

}

}
}

closedir($handle);

}

krsort($categories_array);