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", 
   $this->fileDate[$i] = date("d-M-y H:i", 

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 

Thanks for your insight,


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