what about a bunch of str_replace() things
PHP Code:
<?
function goodName($filename)
{
$filename=str_replace(" ","_",$filename);
// caution, i don't know regex that well so this is probably wrong.
// but use a match that matches only things that are NOT
// alphanumeric chars & underscore
// and replace them with "" nothing.
$filename=preg_replace("[^A-Za-z0-9_]","",$filename);
return $filename;
}
?>