Re: Sorting files in a directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steve Marquez wrote:
Greetings,

I have some code that opens a directory and displays the files. I want to
display the files in Alphabetical order.

I know this code does not work, but I was curious if someone can take a look
and tell me what is wrong? Thank you so much.

[ I hope the indenting is because you're posting to the list - tabs/spaces make it a lot easier to follow what's going on ]

You have this:

$file_array = array($file);
sort ($file_array);

foreach($file_array as $key => $value) {
    echo "<option value=\"$value\">".$value."</option>";
}

You're "sorting" one element of an array and then printing it out.

Not what you want.

Try this cut down version:

http://pastebin.com/m5bcadd77

Also note that in your example, if a directory can't be opened for whatever reason, then you don't get a select box at all - is that what you want to do?

--
Postgresql & php tutorials
http://www.designmagick.com/

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux