如何将西里尔字符翻译成拉丁字母?
E.g. Главная страница -> Glavnaja stranica
这个Transliteration PHP Extension会做得很好,但我无法将其安装在我的服务器上.
最好是在PHP中实现相同的实现.
尝试以下代码
原文链接:https://www.f2er.com/php/140118.html$textcyr="Тествам с кирилица"; $textlat="I pone dotuk raboti!"; $cyr = [ 'а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я','А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я' ]; $lat = [ 'a','b','v','g','d','e','io','zh','z','i','y','k','l','m','n','o','p','r','s','t','u','f','h','ts','ch','sh','sht','a','yu','ya','A','B','V','G','D','E','Io','Zh','Z','I','Y','K','L','M','N','O','P','R','S','T','U','F','H','Ts','Ch','Sh','Sht','Yu','Ya' ]; $textcyr = str_replace($cyr,$lat,$textcyr); $textlat = str_replace($lat,$cyr,$textlat); echo("$textcyr $textlat");