Hi Javier,
I think parsing the listing into a multidemensional array is the answer. But actually, I do not yet know how that would look like in PHP. But I can give you an example of how it is done in ActionScript (Ecmascript). file_arr[n] = [name, date] Now you can sort file_arr by file_arr[n][0] (name) or file_arr[n][1] (date). Hope it helps, Timo Am Dienstag den, 3. September 2002, um 12:27, schrieb Javier Montserat: > 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php