se invece ti interessano solo i file di un certo tipo ( es. .txt)

$files=glob("$folder/*.txt");