TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   List soted folder in combo box (http://www.talkphp.com/general/5157-list-soted-folder-combo-box.html)

Peuplarchie 12-08-2009 03:06 AM

List soted folder in combo box
 
Good day to you all,
here i'm working on a snippet that list the folder in a folder and return is content to a combo box.

My problem is it don't sort.

Here is my code:

PHP Code:



<?PHP
$console 
$_GET['console'];
$dir "Names/";
echo 
"<select name=\"cars\">";
// Open a known directory, and proceed to read its contents
$dir_handle = @opendir($dir) or die("Unable to open $dir");
while(
$file readdir($dir_handle)) {
sort($file);
if(
is_dir($file)) {
if(
$file != '.' && $file != '..') {

}
}
else if(
$file != '.' && $file != '..') {
$filing sort($file);
echo 
"<option value=\"".$path/$filing."\">".$file."</option>";
}
}
?>
</select>


Thanks !

adamdecaf 12-08-2009 03:16 AM

1) Why are you sorting the list/array over and over again?
2) You should try sort($file, SORT_STRING); instead.

Peuplarchie 12-08-2009 03:30 AM

1) I just saw that.
2) where did you took sort_string ?


All times are GMT. The time now is 12:07 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0