Created
December 14, 2011 14:36
-
-
Save vindia/1476814 to your computer and use it in GitHub Desktop.
Russian (cyrillic) transliteration function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function transliterate($string) { | |
$roman = array("Sch","sch",'Yo','Zh','Kh','Ts','Ch','Sh','Yu','ya','yo','zh','kh','ts','ch','sh','yu','ya','A','B','V','G','D','E','Z','I','Y','K','L','M','N','O','P','R','S','T','U','F','','Y','','E','a','b','v','g','d','e','z','i','y','k','l','m','n','o','p','r','s','t','u','f','','y','','e'); | |
$cyrillic = array("Щ","щ",'Ё','Ж','Х','Ц','Ч','Ш','Ю','я','ё','ж','х','ц','ч','ш','ю','я','А','Б','В','Г','Д','Е','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Ь','Ы','Ъ','Э','а','б','в','г','д','е','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','ь','ы','ъ','э'); | |
return str_replace($cyrillic, $roman, $string); | |
} | |
var_dump(transliterate('андрей шевченко')); # andrey shevchenko | |
?> |
One more problem: 'Ю','я','ё'
-> 'Ю','Я','ё'
, and so 'Yu','Ya','yo'
No problem, guys, just use strtoupper(transliterate('андрей шевченко'));
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a little problem:
"АНДРЕЙ ШЕВЧЕНКО" => "ANDREY ShEVChENKO"
:)