print_r (r2e (" ")); function r2e ($txt) { $r=array(mb_strtolower($txt,"windows-1251")); $r=r2es($r,"//i",array("x","ks","cs")); $r=r2es($r,"//i",array("ey","ei")); $r=r2es($r,"//i",array("ov","off")); $r=r2es($r,"//i",array("a")); $r=r2es($r,"//i",array("b")); $r=r2es($r,"//i",array("v","w")); $r=r2es($r,"//i",array("g")); $r=r2es($r,"//i",array("d")); $r=r2es($r,"//i",array("e")); $r=r2es($r,"//i",array("yo","jo")); $r=r2es($r,"//i",array("zh","z")); $r=r2es($r,"//i",array("z","s")); $r=r2es($r,"//i",array("i")); $r=r2es($r,"//i",array("j","y")); $r=r2es($r,"//i",array("k","c")); $r=r2es($r,"//i",array("l")); $r=r2es($r,"//i",array("m")); $r=r2es($r,"//i",array("n")); $r=r2es($r,"//i",array("o")); $r=r2es($r,"//i",array("p")); $r=r2es($r,"//i",array("r")); $r=r2es($r,"//i",array("s")); $r=r2es($r,"//i",array("t")); $r=r2es($r,"//i",array("u")); $r=r2es($r,"//i",array("f")); $r=r2es($r,"//i",array("h","kh")); $r=r2es($r,"//i",array("c","ts")); $r=r2es($r,"//i",array("ch")); $r=r2es($r,"//i",array("sh")); $r=r2es($r,"//i",array("shch","sch","sh")); $r=r2es($r,"//i",array("")); $r=r2es($r,"//i",array("y")); $r=r2es($r,"//i",array("")); $r=r2es($r,"//i",array("e")); $r=r2es($r,"//i",array("u","yu","ju")); $r=r2es($r,"//i",array("ya","ja")); return $r; } function r2es ($var, $pattern, $splits) { $sp=array(); $nsp=array(); foreach ($var as $v) if (preg_match($pattern,$v)) foreach ($splits as $split) $sp=array_merge($sp,array(preg_replace($pattern,$split,$v))); else $nsp=array_merge($nsp,array($v)); return array_merge($sp,$nsp); }