RE: [PHP] sorting files in directory

2002-11-27 Thread James E Hicks III
I've done this by reading the directory contents into an array and then sorting
that array. This really sorts on filename and not date, but your filenames seem
to contain dates so this might work for you.

James Hicks

-Original Message-
From: Nick Wilson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 27, 2002 8:02 AM
To: php-general
Subject: [PHP] sorting files in directory


Hi all,

I have several directories filled with files written like this:

*   02-09-19-filename.etc
*   02-10-02-anotherfile.whatever

How does php order these files if read from the directory and printed to
the screen?  -- I need them in date order, do I need to sort them
somehow?

Many thanks...

--
Nick Wilson //  www.tioka.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




Re: [PHP] sorting files in directory

2002-11-27 Thread Marek Kilimajer
Yes, you do. Add each dir to an array,  sort the array, then loop 
through it printing the dirs out.

Nick Wilson wrote:

Hi all, 

I have several directories filled with files written like this:

*   02-09-19-filename.etc
*   02-10-02-anotherfile.whatever

How does php order these files if read from the directory and printed to
the screen?  -- I need them in date order, do I need to sort them
somehow?

Many thanks...

 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] sorting files in directory

2002-11-27 Thread Marek Kilimajer
Justin French wrote



I think PHP reads them in date created order, or something else... 

The order is not guarantied, it just happens to be so. I suppose most 
filesystems return files
in the order they were added to the directory, but also reuse the space 
left after deleting a
file.

 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] sorting files in directory

2002-11-27 Thread Nick Wilson

* and then Justin French declared
  How does php order these files if read from the directory and printed to
  the screen?  -- I need them in date order, do I need to sort them
  somehow?
 
 There's an optional second parameter for asort() and rsort(), so check it
 out in the manual... it *may* be needed to get what you want.

Great, thanks everyone. Just wondered if it would have problems with
asort() and the dates in the filenames like:

*   02-11-23-whatever.php
*   02-12-03-whatever.php

Cheers...

-- 
Nick Wilson //  www.tioka.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php