Just a couple of things with that. Firstly, I don't know how it works on IIS, but on a *nix machine directories are files, too. Therefore the function returns not only files in the directory but sub directories too (which is fine if that's what you want, but just be aware that it's happening). Also, due to the way while loops work you will always receive one empty array on the end which serves no purpose.
Here's a slight re-working which strips out all directories and empty arrays and leaves you just the filenames:
PHP Code:
function get_filenames($dir='.') {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
$check_file = (!empty($file) && !is_dir($file) ? $file : '');
if(!empty($check_file)) {
$return_file[] = $check_file;
}
}
closedir($handle);
return $return_file;
}
}
print_r(get_filenames());