while ( $file = readdir( $imgDir ) )
{
//checks that file is an image
$file_type = strrchr( $file, "." );
$is_image = eregi( "jpg|gif",$file_type );
$is_hidden = substr($file,0,1); // This grabs if the first character of the filename.
if ( $file != '.' && $file != '..' && $is_image && $is_hidden != '.' ) // Added the is_hidden variable to the conditional statement to not include any files that starts with a period (".").
{ $images[$i++] = $file; }
}