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); }
$sqlstr = "SELECT <smth> FROM <smwhr> WHERE searchField LIKE '%" . implode("%' OR searchField LIKE '%",$result) . "%'"; , $sqlstr = "SELECT <smth> FROM <smwhr> WHERE searchField LIKE '" . implode("' OR searchField LIKE '",$result) . "'";
function r2e ($txt) { $txt=mb_strtolower($txt,"windows-1251"); $sr=array("","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""); $se=array("(x|[kc]s)","e[yi]","o(v|ff)","a","b","[vw]","g","d","e","[yj]o","z(h)*","[zs]","i","[jy]","[kc]","l","m","n","o","p","r","s","t","u","f","(k|c)*h","(c|ts)","ch","sh","s(h)*(c)*h","","y","","e","[yj]*u","[yj]a"); return str_replace($sr,$se,$txt); }
ochen prosta[yj]a fra[zs]a na russ[kc]om [yj]a[zs]y[kc]e
Source: https://habr.com/ru/post/202528/
All Articles