Bit of a problem with some code I am using, seems like ths sort won't work on the second set.
if ($handle = opendir("$basedir")){
while (false !== ($file2 = readdir($handle))){
if ($file2 != "." && $file2 != ".." && $file2 != "background" && $file2 !="images" && is_dir("$basedir/$file2")){
$file = $file2;
$list[] = $file2;
}
}
closedir($handle);
sort($list);
reset($list);
while(list($key,$val) = each($list)){
$name = str_replace("_"," ",$val);
$script .= "<option value=\"$val\">$name</option>\n";
$together = "$basedir/$val";
$together = str_replace("//","/",$together);
if ($imgdir = opendir("$together")){
while (($img_file = readdir($imgdir))){
if ($img_file != "." && $img_file != ".."){
$cachedimgs .= "'battleimages/$val/$img_file/win.gif', ";
$bat_o[$i][] = "O(\"$img_file\",\"$val/$img_file\");\n";
}
}
}
closedir($imgdir);
$i++;
}
}
$script .= "</select>";
$opts = "";
$i=0;
while(list($key,$val) = each($bat_o)) {
$size=count($val);
$opts .= "newCat();\n";
for($h=0;$h<=$size;$h++) {
$opts .= $bat_o[$i][$h];
}
$i++;
}
To say the least, the purpose is to make a category drop down, containing which game the file is from, and then select an image from there. The code itself works perfect, and I have had no trouble with using it. However, the second set, where the images are located (though it is actually a directory) I cannot get to sort by name, unless I reupload all of the files in the correct order. The sort($list) will work fine, but when I try to sort the second set, I get an error like "incorrect datatype for sort()". Any suggestions to clear that up? I figure it needs to be sorted before the $bat_o[$i] array.