Jump to content


Help with sorting


4 replies to this topic

#1 eivindlt

    Young Padawan

  • Members
  • Pip
  • 47 posts

Posted 18 September 2005 - 04:52 AM

Hi!
I've been using a file archive for a while now. I downloaded it (I'm a newbie) from mortz.tjokk.net (a norwegian site). The files are automatically sorted by name. How can I sort the files by the date they are uploaded?

Here is the sort-part (i think :) ) of the code:
      sort($files);

      $length = strlen($dir);
      if ($length >= $MaxLenFilename) {
         $length = $MaxLenFilename-3;
         $displaydir = substr($dir, 0, $length) . "...";
      }
      else $displaydir = $dir;

      if (count($files) != 0) {
         echo "<tr><td colspan=\"5\">&nbsp;</td></tr>\n";
            echo "<tr><td colspan=\"3\"><b>$displaydir</b></td><td><b>St&oslash;rr.:</b></td></tr>\n";
      }

The full code can be seen here

Thanks for helping :huh:

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 18 September 2005 - 07:41 PM

As far as i know, php has no way to figure out the "last modified" time of a file. I know javascript does, and php MAY have the capablity to do so also... but i've never found a way to do so...

#3 eivindlt

    Young Padawan

  • Members
  • Pip
  • 47 posts

Posted 19 September 2005 - 02:53 AM

Okey, so I can't sort them... Damn :rolleyes:

#4 fiv3isaliv3

    Young Padawan

  • Members
  • Pip
  • 258 posts
  • Gender:Male

Posted 19 September 2005 - 02:23 PM

tie it in with a database and just put the date it was modified in there maybe. just a thought.

#5 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 19 September 2005 - 03:32 PM

Mild correction in my last statement.
http://php.net/manua...n.filemtime.php

I completely forgot about that set of functions





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users