i have the following code which reads a list of files from a directory -

$listcmd = "ls " .$dirPath;
$temp = exec($listcmd, $listoffiles, $status);
if($status == 0) {
for ($i =0; $i < sizeof($listoffiles); $i++) {
   $this->fileName[$i] = $listoffiles[$i];
   $this->sizeofFile[$i] = sprintf("%01.2f", 
(filesize($dirPath."/".$listoffiles[$i])/1024)/1024);
   $this->fileDate[$i] = date("d-M-y H:i", 
filemtime($dirPath."/".$listoffiles[$i]));
}
$this->displayFiles();

What I want to do is display the files sorted by date.

Okay, so I've just realised that the really easy way to do this is by adding 
-St (sort by time) to the ls command...

$listcmd = "ls -St " .$dirPath;

But how could this be achieved by sorting the three arrays?  What if I 
alternately wanted to sort the files by name, size or date without 
re-reading the directory each time?

Would an associative array structure be better suited to this type of 
operation?

Thanks for your insight,

Javier

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to