Skip to content

Instantly share code, notes, and snippets.

@LastDreamer
Created September 17, 2014 14:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LastDreamer/b248e20d982b3dbff311 to your computer and use it in GitHub Desktop.
Save LastDreamer/b248e20d982b3dbff311 to your computer and use it in GitHub Desktop.
yandex transliteration function
<?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