+ function slug(string $string): string {
+ //Use Transliterator if available
+ if (class_exists('Transliterator')) {
+ $trans = Transliterator::create('Any-Latin; Latin-ASCII; Lower()');
+ return preg_replace(['/[^a-zA-Z0-9]+/', '/(^-+|-+$)/'], ['-', ''], $trans->transliterate($string));
+ }