Cyrillic transliteration in PHP?

Try following code $textcyr="Теѝтвам ѝ кирилица"; $textlat="I pone dotuk raboti! "; $cyr = array('а','б','в','г','д','e','ж','з','и','й','к','л','м','н','о','п','р','ѝ','т','у', 'ф','х','ц','ч','ш','щ','ъ','ь', 'ю','ѝ','Н','Б','В','Г','Д','Е','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У', 'Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ь', 'Ю','Я' ); $lat = array( 'a','b','v','g','d','e','zh','z','i','y','k','l','m','n','o','p','r','s','t','u', 'f' ,'h' ,'ts' ,'ch','sh' ,'sht' ,'a' ,'y' ,'yu' ,'ya','A','B','V','G','D','E','Zh', 'Z','I','Y','K','L','M','N','O','P','R','S','T','U', 'F' ,'H' ,'Ts' ,'Ch','Sh' ,'Sht' ,'A' ,'Y' ,'Yu' ,'Ya' ); $textcyr = str_replace($cyr, $lat, $textcyr); $textlat = str_replace($lat, $cyr, $textlat); echo("$textcyr $textlat").

You should try iconv() with the //TRANSLIT option. $trstr = iconv(, "ISO-8859-1//TRANSLIT", $src_str).

I would had bet that this was the correct answer but iconv() does not seem to support transliteration on Cyrillic characters. – Álvaro G. Vicario Nov 27 at 13:51 Ah, I see, iconv() doesn't have that transliteration scheme.

ICU does, though, so if your PHP is compiled with ICU, you can use transliterate?. (You might need to aptitude install php5-intl that on your Debian-based machine. ) – Kerrek SB Nov 27 at 14:09.

Tural Teyyuboglu Your code has a problem: if you try to transliterate for example "щеки" to latin and then back to cyrillic it will produce something like "ѝхтеки". The multi-byte characters must appear first in the array like this: function transliterate($textcyr = null, $textlat = null) { $cyr = array( 'ж', 'ч', 'щ', 'ш', 'ю', 'а', 'б', 'в', 'г', 'д', 'e', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'ѝ', 'т', 'у', 'ф', 'х', 'ц', 'ъ', 'ь', 'ѝ', 'Ж', 'Ч', 'Щ', 'Ш', 'Ю', 'Н', 'Б', 'В', 'Г', 'Д', 'Е', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ъ', 'Ь', 'Я'); $lat = array( 'zh', 'ch', 'sht', 'sh', 'yu', 'a', 'b', 'v', 'g', 'd', 'e', 'z', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'c', 'y', 'x', 'q', 'Zh', 'Ch', 'Sht', 'Sh', 'Yu', 'A', 'B', 'V', 'G', 'D', 'E', 'Z', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'H', 'c', 'Y', 'X', 'Q'); if($textcyr) return str_replace($cyr, $lat, $textcyr); else if($textlat) return str_replace($lat, $cyr, $textlat); else return null; } echo transliterate(null, transliterate("щеки")) == "щеки.

I tested my code with 40k words from the dictionary and it has flaws in cases like "безизходен" -> "bezizhoden" -> "безижоден". If I manage to find a solition that both keeps human readability and is loseless I will post the solution (on my site). – bobef Dec 1 at 10:28.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions