Last active
July 21, 2018 14:07
-
-
Save artemsites/87babaeb23c1ad1809c388c4428cd8a6 to your computer and use it in GitHub Desktop.
Транслитерация массива русских символов в строку английских символов
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
$array_string = array( | |
0 => "Ч", | |
1 => "е", | |
2 => "л", | |
3 => "о", | |
4 => "Б", | |
5 => "р", | |
6 => "е", | |
7 => "й", | |
8 => "к" | |
); | |
function transliterator_rus_array($array_string) { | |
$array_letters = array( | |
'а' => 'a', 'б' => 'b', 'в' => 'v', | |
'г' => 'g', 'д' => 'd', 'е' => 'e', | |
'ё' => 'e', 'ж' => 'zh', 'з' => 'z', | |
'и' => 'i', 'й' => 'y', 'к' => 'k', | |
'л' => 'l', 'м' => 'm', 'н' => 'n', | |
'о' => 'o', 'п' => 'p', 'р' => 'r', | |
'с' => 's', 'т' => 't', 'у' => 'u', | |
'ф' => 'f', 'х' => 'h', 'ц' => 'c', | |
'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch', | |
'ь' => '\'', 'ы' => 'y', 'ъ' => '\'', | |
'э' => 'e', 'ю' => 'yu', 'я' => 'ya', | |
'А' => 'A', 'Б' => 'B', 'В' => 'V', | |
'Г' => 'G', 'Д' => 'D', 'Е' => 'E', | |
'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z', | |
'И' => 'I', 'Й' => 'Y', 'К' => 'K', | |
'Л' => 'L', 'М' => 'M', 'Н' => 'N', | |
'О' => 'O', 'П' => 'P', 'Р' => 'R', | |
'С' => 'S', 'Т' => 'T', 'У' => 'U', | |
'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', | |
'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch', | |
'Ь' => '\'', 'Ы' => 'Y', 'Ъ' => '\'', | |
'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya', | |
); | |
foreach($array_string as $value) { | |
// var_dump($value); | |
if (array_key_exists($value, $array_letters)) { | |
$trans_string .= $array_letters[$value]; | |
} | |
// var_dump($trans_string); | |
} | |
return $trans_string; | |
} | |
print_r( transliterator_rus_array($array_string) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment