TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-08-2009, 03:06 AM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application 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 !
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 12-08-2009, 03:16 AM   #2 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

1) Why are you sorting the list/array over and over again?
2) You should try sort($file, SORT_STRING); instead.
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 12-08-2009, 03:30 AM   #3 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Default

1) I just saw that.
2) where did you took sort_string ?
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
Talkphp's List of Knowledge codefreek General 0 08-06-2009 01:01 AM
Listing folders in list box, folder only, recursively Peuplarchie General 1 06-28-2009 08:59 PM
Status List codefreek TalkPHP Developer Team 12 11-24-2008 12:23 AM
list populating proplem Peuplarchie Absolute Beginners 7 06-09-2008 09:02 AM


All times are GMT. The time now is 11:42 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design