Siempre hay truquillos
Ahí va:
Antes del bucle o tu opendir
pones
Código PHP:
static $array=array();
luego dentro del bucle:
pones:
Código PHP:
array_push($array,$VARIABLE_DE_TUS_ARHIVOS);
luego del closedir
pones:
Código PHP:
usort($array, "OrganizarPorNombre");
return $array;
y pegas en tu archivo la función:
Código PHP:
// (c) www.recursoswebmasters.com
function OrganizarPorNombre($primero, $segundo) {
$nombre[0]=strtoupper($primero);
$nombre[1]=strtoupper($segundo);
sort($nombre);
return (strcmp(strtoupper($nombre[1]) , strtoupper($segundo))) ? 1 : -1;
}
Saludos.