My below function sanitize uploaded files:
public static function slugify($string) {
$string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string);
$string = preg_replace('/[-\s]+/', '-', $string);
return trim($string, '-');
}
Here I have [:Punctuation:]
to remove puctuations. The problem is that I want to keep dot(.) in my file names, because when I remove it, slugify turns 1.zip
to 1zip
. Is there a way to keep dot with this function?