function clean_filename($string) { $string = convert_high_ascii($string); $string = eregi_replace("\\.\\.+", '', $string); $string = preg_replace('/[^\\.a-zA-Z\\d\\_-]/', '_', $string); // only allowed chars $string = eregi_replace("_+", '_', $string); return $string; }
function iso_dirify($s, $sep = '_') { if ($sep == '1') { $sep = '_'; } $s = convert_high_ascii($s); ## convert high-ASCII chars to 7bit. $s = strtolower($s); ## lower-case. $s = strip_tags($s); ## remove HTML tags. $s = preg_replace('!&[^;\\s]+;!', '', $s); ## remove HTML entities. $s = preg_replace('![^\\w\\s]!', '', $s); ## remove non-word/space chars. $s = preg_replace('/\\s+/', $sep, $s); ## change space chars to underscores. return $s; }