might be you are having hidden files in your directory
what platform are your using , WiNDOWS OR Linux ,
If you just want to exclude files starting with a dot, ".",
try this:
$files = readdir('/path/to/folder');
$files = array_filter($files, create_function('$a','return ($a[0]!=".");'));
the above function only returs the files , chich are not starting with .
but on windows hidden files works differently , i dont know how to play with it .