Apache directory listing and PHP script

Discussion in 'Web Design and Development' started by Poeben, Dec 15, 2006.

  1. Poeben macrumors 6502

    Jul 29, 2004

    So I'm having a problem with a PHP script I wrote. The basic idea is to take a directory listing of a folder using readdir() and put the file names into an array. I then pull the file names from the array and display in a table as links. The goal is for the files to be listed basically in alphabetical order (actually they begin with the date.) The file names look like this:

    where the date is in yyyymmdd format, and the #01, #02, ..., should order files with similar dates

    The problem I am having is that on my webserver the files are not being listed in the correct order. Everything works fine on my local machine (10.3.9). Are there Apache options for directory listing (ex. by name, size, date etc..) that can be configured with a .htaccess file or something?

    thanks for any help,

  2. iMeowbot macrumors G3


    Aug 30, 2003
    Some filesystems keep directories sorted, some don't. A sort() before you do the output ought to, um, sort it out.

    several examples over at php.net
  3. Poeben thread starter macrumors 6502

    Jul 29, 2004
    Thanks iMeowbot. That did it, nice and easy. I can't believe I didn't think of that, doh!

Share This Page