Created
September 17, 2014 14:32
-
-
Save LastDreamer/b248e20d982b3dbff311 to your computer and use it in GitHub Desktop.
yandex transliteration function
This file contains 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 translit_ya($str) | |
{ | |
$dict = array('а'=>'a','б'=>'b','в'=>'v','г'=>'g','д'=>'d','е'=>'e','ё'=>'yo','ж'=>'zh','з'=>'z','и'=>'i','й'=>'j','к'=>'k','л'=>'l','м'=>'m','н'=>'n','о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t','у'=>'u','ф'=>'f','х'=>'h','ц'=>'c','ч'=>'ch','ш'=>'sh','щ'=>'sch','ъ'=>'','ы'=>'y','ь'=>'','э'=>'e','ю'=>'yu','я'=>'ya',' '=>'_','–'=>'-','—'=>'-','&'=>'_','"'=>'','<'=>'','>'=>'','…'=>'','′'=>'','″'=>'','‘'=>'','’'=>'','‚'=>'','“'=>'','”'=>'','„'=>'','«'=>'','»'=>'', ' '=>'_'); | |
return preg_replace("/_+/", "_", strtr(mb_strtolower($str, mb_detect_encoding($str)), $dict)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment