function slugify($string) {
$string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string);
$string = preg_replace('/[-\s]+/', '-', $string);
$string = trim($string, '-');
echo slugify("Я люблю PHP!");
$string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string);
$string = preg_replace('/[-\s]+/', '-', $string);
$string = trim($string, '-');
return preg_replace('/[^-\s\d\w]/','',$string);}
echo slugify("Я люблю PHP!");
Комментарии
Отправить комментарий