Sorting the output (opendir() and readdir())

From: Date: Sat, 12 Jan 2002 10:42:49 +0000
Subject: Sorting the output (opendir() and readdir())
Groups: php.db 
Request: Send a blank email to php-db+get-15693@lists.php.net to get a copy of this message
we have a directory with pics, that a user can associate with his data in a form. we use opendir/readdir to show the directory contents. unfortunately, this is not sorted. How can we achieve a listing in alphabetical order? this is our code: echo "<select name='image'>"; echo "<option value=''>please select</option>"; $fp = opendir("../pics/"); while ($file = readdir($fp)) { $selectfile="/pics/".$file; if ($file=="." OR $file=="..") { } else { $string_image .= "<option value='/pics/".$file."'"; if ($selectfile==$image) { $string_image .= " SELECTED"; } $string_image .= ">".$file."</option>"; } } echo $string_image; echo "</select>";

« previous php.db (#15693) next »