http://it2.php.net/opendir

prendi il primo esempio e invece di fare echo metti tutto in un array