List soted folder in combo box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

List soted folder in combo box

Post by Peuplarchie »

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:

Code: Select all

 
 
 
<?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 !
Post Reply