Re: File ordering

From: Date: Tue, 12 Aug 2003 12:32:40 +0000
Subject: Re: File ordering
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-159273@lists.php.net to get a copy of this message
> I am doing a 'readdir' on a subdirectory. I did my file naming counting on > it ordering based on numbering... But when I do the readdir it isn't doing > it. My naming convention 002_2003_66.jpg would indicate the 66th picture for > the month of Feb in 2003. This gave me automatic sorting. So I thought. But > it doesn't seem to be doing it. The server is a linux server > ((IStop/Doncaster consulting) and I don't see why the ordering is screwing > up. I checked the create dates and that isn't the ordering choosen (I have > pictures from July showing up between pictures from March). > > Thoughts, suggestions? > > Katherine > > This is the clip of code(srcdir being passed in): > > $imgdir = "$srcdir/images"; > $txtdir = "$srcdir/txt"; > $imgdh = opendir($imgdir); > $txtdh = opendir($txtdir); > > while($file = readdir($imgdh)) { > if(substr($file,-3)=="jpg") { > $imgFiles[] = $file; > $textFileName = substr($file,0,-3)."txt"; > $textFiles[] = $textFileName; > } > } Just sort the $imgFiles array. -- Lowell Allen

« previous php.general (#159273) next »