[PHP] RE: sorting results of opendir()

2001-07-09 Thread Andrew Chase

Try reading the directory contents into an array, sorting it, *then*
outputting the contents of the array:

$dir = opendir(.);

$dirlist = array();
$index = 0;
while($file = readdir($dir)  $file != .  $file != ..){
$dirlist[$index++] = $file;
}

sort($dirlist);

foreach($dirlist as $file){
echo $filebr;
}



 -Original Message-
 From: kmurrah [mailto:[EMAIL PROTECTED]]
 Sent: Monday, July 09, 2001 11:06 AM
 To: [EMAIL PROTECTED]
 Subject: sorting results of opendir()


 Greetings.

 I need to read the contents of a directory, sort it alphabetically, and
 display it 

 i'm doing find on the reading and displaying, but can someone help me with
 the sort?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] RE: sorting results of opendir()

2001-07-09 Thread Don Read


On 09-Jul-01 Andrew Chase wrote:
 Try reading the directory contents into an array, sorting it, *then*
 outputting the contents of the array:
 
 $dir = opendir(.);
 
 $dirlist = array();
 $index = 0;
 while($file = readdir($dir)  $file != .  $file != ..){
   $dirlist[$index++] = $file;
 }
 
 sort($dirlist);
 
 foreach($dirlist as $file){
   echo $filebr;
 }
 
 

errmmm ...

$ls=`ls`;
echo nl2br($ls);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]