public static function sanitizeFileName( $filename ) {
		$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
		$filename = str_replace($special_chars, '', $filename);
		$filename = preg_replace('/[\s-]+/', '-', $filename);
		$filename = trim($filename, '.-_');

		return $filename;
		
	}
public static function sanitizeFileName( $filename ) {
		$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
		$filename = str_replace($special_chars, '', $filename);
		$filename = preg_replace('/[\s-]+/', '-', $filename);
		$filename = trim($filename, '.-_');

		return $filename;
		
	}
public static function sanitizeFileName ( $ filename ) { $ special_chars = array ( "?" , "[" , "]" , "/" , "\\" , "=" , "<" , ">" , ":" , ";" , "," , "'" , "\"" , "&" , "$" , "#" , "*" , "(" , ")" , "|" , "~" , "`" , "!" , "{" , "}" , chr ( 0 ) ) ; $ filename = str_replace ( $ special_chars , '' , $ filename ) ; $ filename = preg_replace ( '/[\s-]+/' , '-' , $ filename ) ; $ filename = trim ( $ filename , '.-_' ) ; return $ filename ; }
Sanitizes a filename replacing whitespace with dashes

Removes special characters that are illegal in filenames on certain
operating systems and special characters requiring special escaping
to manipulate at the command line. Replaces spaces and consecutive
dashes with a single dash. Trim period, dash and underscore from beginning
and end of filename.

@param string $filename The filename to be sanitized
@return string The sanitized filename
Sanitizes a filename replacing whitespace with dashes