我有这段代码,它从指定目录读取文件,并将内容输出到下拉菜单中。问题是所有文件都没有按字母数字顺序列出。他们都乱七八糟了!无论如何,这是代码:
<form name="index1">
<select name="menu" onchange="jump(this.form)">
<?php
$dir = opendir($dirname);
echo '<option value="">Choose a chapter or volume</option>';
while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != "..") and ($file != "afile.php")){
$name = basename($file,".php");
echo "<option value=".$file.">$name</option>";
}
}
?>
</select>
</form>
我究竟做错了什么?