I'd like to sort an array which consists of two entries, a filename (instead of the default increasing key number) and a timestamp of when the file has been created.
my script looks like this:
however the timestamp-value is not applied, instead I get the regular key entries. print_r($files) gives me the following:
but I want to have this:
without doing an multi-dimesional array.
afterwards I'd like it to sort the keys according to its timestamp. suppose I'd net sort($files) then?
thanks in advance.
my script looks like this:
Code:
while ($file = readdir ($dir)) {
$timestamp = filemtime($file);
$files[$timestamp] = $file;
}
however the timestamp-value is not applied, instead I get the regular key entries. print_r($files) gives me the following:
Code:
Array
(
[0] => filename0.txt
[1] => filename1.txt
[2] => filename2.txt
[3] => filename3.txt
)
but I want to have this:
Code:
Array
(
[1111674409] => filename0.txt
[1106323078] => filename1.txt
[1110561128] => filename2.txt
[1107435271] => filename3.txt
)
without doing an multi-dimesional array.
afterwards I'd like it to sort the keys according to its timestamp. suppose I'd net sort($files) then?
thanks in advance.