login about faq

I am connecting to a linux server using ssh. I want to list all the files in a directory. I got that part working however they are not in the order I would like. I want to sort by creating date.

Here is the code I am using

$dirListing = $sftp->ReadDir($handle);

if (is_null($dirListing)) { print $sftp->lastErrorHtml() . "n"; exit; }

// Iterate over the files. $sysTime = new SYSTEMTIME();

$n = $dirListing->get_NumFilesAndDirs(); if ($n == 0) { print 'No entries found in this directory.' . "n"; } else { print '

'; print ' '; for ($i = 0; $i <= $n - 1; $i++) {

    $fileObj = $dirListing->GetFileObject($i);

    $filetype = $fileObj->fileType();

    if($filetype != "directory") {
    ?>
    <tr>  
        <td scope="col"><?php print $fileObj->filename(); ?></td>
        <td scope="col"><?php print formatBytes($fileObj->get_Size32()); ?></td>
        <td scope="col"><?php $fileObj->get_CreateTime($sysTime);print $sysTime->wHour . ":" . $sysTime->wMinute . ' '. $sysTime->wMonth . '/'.$sysTime->wDay. '/'.$sysTime->wYear ."\n"; ?></td>
        <td scope="col">&nbsp;</td>
    </tr>
    <?php 
    }
}
print '</tbody></table> ';

}

How do I sort the directory listing by date?

File Name File Size Created  

asked Aug 23 '12 at 11:17

kevindcs's gravatar image

kevindcs
11556

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×200
×89
×17
×10
×1

Asked: Aug 23 '12 at 11:17

Seen: 1,746 times

Last updated: Aug 23 '12 at 11:17

powered by OSQA