<html>
<head>
<title>
Перевод с русского на транслит и наоборот
</title>
</head>
<body>
<form action=translit.php method=POST>
Текст:<br>
<textarea name=txt rows=4 cols=40>
<?php
if (isset($txt)) echo $txt;
?>
</textarea>
<br>
<input type=radio name=tr value=ru checked=true> Перевести на транслит <br>
<input type=radio name=tr value=eng> Перевести на русский <br>
<input type=submit value=Перевести>
</form>
<?php
if (isset($txt))
{
$txt = StrToLower($txt);
if ($tr==='ru')
{
$txt = str_replace('а','a',$txt);
$txt = str_replace('б','b',$txt);
$txt = str_replace('в','v',$txt);
$txt = str_replace('г','g',$txt);
$txt = str_replace('д','d',$txt);
$txt = str_replace('е','e',$txt);
$txt = str_replace('ж','zh',$txt);
$txt = str_replace('з','z',$txt);
$txt = str_replace('и','i',$txt);
$txt = str_replace('й','j',$txt);
$txt = str_replace('к','k',$txt);
$txt = str_replace('л','l',$txt);
$txt = str_replace('м','m',$txt);
$txt = str_replace('н','n',$txt);
$txt = str_replace('о','o',$txt);
$txt = str_replace('п','p',$txt);
$txt = str_replace('р','r',$txt);
$txt = str_replace('с','s',$txt);
$txt = str_replace('т','t',$txt);
$txt = str_replace('у','u',$txt);
$txt = str_replace('ф','f',$txt);
$txt = str_replace('х','h',$txt);
$txt = str_replace('ц','c',$txt);
$txt = str_replace('ч','ch',$txt);
$txt = str_replace('ш','sh',$txt);
$txt = str_replace('щ','sch',$txt);
$txt = str_replace('ъ','\'',$txt);
$txt = str_replace('ы','y',$txt);
$txt = str_replace('ь','\'',$txt);
$txt = str_replace('э',']',$txt);
$txt = str_replace('ю','yu',$txt);
$txt = str_replace('я','ya',$txt);
}
if ($tr==='eng')
{
$txt = str_replace('sch','щ',$txt);
$txt = str_replace('yu','ю',$txt);
$txt = str_replace('ya','я',$txt);
$txt = str_replace('ch','ч',$txt);
$txt = str_replace('sh','ш',$txt);
$txt = str_replace('a','а',$txt);
$txt = str_replace('b','б',$txt);
$txt = str_replace('v','в',$txt);
$txt = str_replace('g','г',$txt);
$txt = str_replace('d','д',$txt);
$txt = str_replace('e','е',$txt);
$txt = str_replace('zh','ж',$txt);
$txt = str_replace('z','з',$txt);
$txt = str_replace('i','и',$txt);
$txt = str_replace('j','й',$txt);
$txt = str_replace('k','к',$txt);
$txt = str_replace('l','л',$txt);
$txt = str_replace('m','м',$txt);
$txt = str_replace('n','н',$txt);
$txt = str_replace('o','о',$txt);
$txt = str_replace('p','п',$txt);
$txt = str_replace('r','р',$txt);
$txt = str_replace('s','с',$txt);
$txt = str_replace('t','т',$txt);
$txt = str_replace('u','у',$txt);
$txt = str_replace('f','ф',$txt);
$txt = str_replace('h','х',$txt);
$txt = str_replace('c','ц',$txt);
$txt = str_replace('\'','ъ',$txt);
$txt = str_replace('y','ы',$txt);
$txt = str_replace('\'','ь',$txt);
$txt = str_replace(']','э',$txt);
}
echo 'Результат: <br><b>'.$txt;
}
?>
</body>
</html>
|