Answer the question
In order to leave comments, you need to log in
How to use Transliterator?
There is a need to transliterate the string. Connected the INTL module. And how to use this miracle.
It is elementary to translate the line
$str = "Hello everyone";
php.net/manual/ru/class.transliterator.php
I didn't understand anything in the documentation.
Answer the question
In order to leave comments, you need to log in
function slugify($string) {
$translit = "Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();";
$string = transliterator_transliterate($translit, $string);
$string = preg_replace('/[-\s]+/', '-', $string);
return trim($string, '-');
}
echo slugify("Я люблю PHP!");
A simplified version, without lighting up the docks by transliteration:
transliterator_transliterate('Latin-ASCII', transliterator_transliterate('Latin', $sourceString));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question