Great url slugger

Found a great transliterator, that will compose a readable url for any language taken.

$slug = function($str)
{
$str = transliterator_transliterate('Any-Latin; NFD; [:Nonspacing Mark:] Remove; Latin-ASCII; [\u0080-\uffff] Remove; Lower();', $str);
$str = strtolower($str);
$str = preg_replace('/[^a-z0-9]/i', '-', $str);
$str = preg_replace('/-+/', '-', $str);
$str = preg_replace('/-$|^-/', '', $str);

return $str ?: '-';
}
Show your support

Clapping shows how much you appreciated Oprokidnev A.’s story.