Created
November 6, 2015 15:11
-
-
Save p9436/48cc956dd2bd7ef2b3fd to your computer and use it in GitHub Desktop.
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 | |
| // стандарт КМУ2010 http://zakon5.rada.gov.ua/laws/show/55-2010-%D0%BF | |
| function cyr2lat($string) { | |
| $ukr = ['Є', 'Ї', 'Й', 'Ю', 'Я', 'є', 'ї', 'й', 'ю', 'я' ]; | |
| $lat = ['Ye', 'Yi', 'Y', 'Yu', 'Ya', 'ye', 'yi', 'y', 'yu', 'ya' ]; | |
| for ($i=0,$ic=sizeof($ukr); $i < $ic; $i++) { | |
| $string = preg_replace("/(^|\s)".$ukr[$i]."/u", '$1'.$lat[$i], $string); | |
| } | |
| $string = preg_replace("/([зЗ])(г)/u", '$1gh', $string); | |
| $string = preg_replace("/([зЗ])(Г)/u", '$1Gh', $string); | |
| $cyr = ['а','б','в','г','ґ','д','е','є','ж','з','и','і','ї','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ь','ю','я','А','Б','В','Г','Ґ','Д','Е','Є','Ж','З','И','І','Ї','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ь','Ю','Я']; | |
| $lat = ['a','b','v','h','g','d','e','ie','zh','z','y','i','i','i','k','l','m','n','o','p','r','s','t','u','f','kh','ts','ch','sh','shch','','iu','ia','A','B','V','H','G','D','E','Ie','Zh','Z','Y','I','I','I','K','L','M','N','O','P','R','S','T','U','F','Kh','Ts','Ch','Sh','Shch','','Iu','Ia']; | |
| $string = str_replace($cyr, $lat, $string); | |
| return $string; | |
| } | |
| // На початку слова | |
| // 'Є' 'Ye' | |
| // 'Ї' 'Yi' | |
| // 'Й' 'Y' | |
| // 'Ю' 'Yu' | |
| // 'Я' 'Ya' | |
| // 'є' 'ye' | |
| // 'ї' 'yi' | |
| // 'й' 'y' | |
| // 'ю' 'yu' | |
| // 'я' 'ya' | |
| // Після літери "з" вживається "gh" | |
| // 'г' 'gh' | |
| // 'Г' 'GH' | |
| // Проста заміна | |
| // 'А' 'a' | |
| // 'Б' 'b' | |
| // 'В' 'v' | |
| // 'Г' 'h' | |
| // 'Ґ' 'g' | |
| // 'Д' 'd' | |
| // 'Е' 'e' | |
| // 'Є' 'ie' | |
| // 'Ж' 'zh' | |
| // 'З' 'z' | |
| // 'И' 'y' | |
| // 'І' 'i' | |
| // 'Ї' 'i' | |
| // 'Й' 'i' | |
| // 'К' 'k' | |
| // 'Л' 'l' | |
| // 'М' 'm' | |
| // 'Н' 'n' | |
| // 'О' 'o' | |
| // 'П' 'p' | |
| // 'Р' 'r' | |
| // 'С' 's' | |
| // 'Т' 't' | |
| // 'У' 'u' | |
| // 'Ф' 'f' | |
| // 'Х' 'kh' | |
| // 'Ц' 'ts' | |
| // 'Ч' 'ch' | |
| // 'Ш' 'sh' | |
| // 'Щ' 'shch' | |
| // 'Ь' '' | |
| // 'Ю' 'iu' | |
| // 'Я' 'ia' | |
| // 'А' 'A' | |
| // 'Б' 'B' | |
| // 'В' 'V' | |
| // 'Г' 'H' | |
| // 'Ґ' 'G' | |
| // 'Д' 'D' | |
| // 'Е' 'E' | |
| // 'Є' 'Ie' | |
| // 'Ж' 'Zh' | |
| // 'З' 'Z' | |
| // 'И' 'Y' | |
| // 'І' 'I' | |
| // 'Ї' 'I' | |
| // 'Й' 'I' | |
| // 'К' 'K' | |
| // 'Л' 'L' | |
| // 'М' 'M' | |
| // 'Н' 'N' | |
| // 'О' 'O' | |
| // 'П' 'P' | |
| // 'Р' 'R' | |
| // 'С' 'S' | |
| // 'Т' 'T' | |
| // 'У' 'U' | |
| // 'Ф' 'F' | |
| // 'Х' 'Kh' | |
| // 'Ц' 'Ts' | |
| // 'Ч' 'Ch' | |
| // 'Ш' 'Sh' | |
| // 'Щ' 'Shch' | |
| // 'Ь' '' | |
| // 'Ю' 'Iu' | |
| // 'Я' 'Ia' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment