Re: Re: [PHP] Directory & Array

From: Date: Thu, 06 Jul 2000 03:05:05 +0000
Subject: Re: Re: [PHP] Directory & Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5149@lists.php.net to get a copy of this message
On 5 Jul, Nathan Purciful wrote: > This isnt working either > > <?php > $dir = opendir('.') or die('Could not open dir.'); > while ($file = readdir($dir)){ > $files[] = $file; > } > closedir($dir); > sort($files); > reset($files); > while (list($k, $v) = each($files)){ > echo $v, "<BR>\n"; > } > ?> > OutPut: > . > .. > .htaccess > ImageLibrary > New Folder > centralokhog > corporate > devzone > dir.php > entrance > index.php > services > webexplorer10rc1 > This seems to be the expected output, based on an ASCII sort - ie the sort is done on the basis of the ASCII value of the characters in the strings being sorted. If you want a case insensitive sort, you may have to use usort and write your own routine to make upper and lower case letters the same. Hint - the difference between an upper case and lower case letter in ASCII is 32 (decimal). Cheers -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#5149) next »