Skip to content

Instantly share code, notes, and snippets.

@vindia
Created December 14, 2011 14:36
Show Gist options
  • Save vindia/1476814 to your computer and use it in GitHub Desktop.
Save vindia/1476814 to your computer and use it in GitHub Desktop.
Russian (cyrillic) transliteration function
<?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
?>
@mrmakko
Copy link

mrmakko commented Oct 3, 2016

Just a little problem:
"АНДРЕЙ ШЕВЧЕНКО" => "ANDREY ShEVChENKO"
:)

@mingalevme
Copy link

mingalevme commented Jun 28, 2017

One more problem: 'Ю','я','ё' -> 'Ю','Я','ё', and so 'Yu','Ya','yo'

@almazka987
Copy link

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