2011-12-09 2 views
2

내 Latin5 문자와 일치하는 검색 결과를 얻으려면 어떻게해야이 코드를 수정할 수 있습니까?Latin5 문자 집합에 대한 preg_match

while (preg_match("/([-]?)\"([^\"]+)\"/i", $a, $regs)) 

다른 코드 (I는 "C"로 시작하는 단어를 조회 할 때, 나는 문자 "C"또는 "c"또는 "c"또는 "C"로 시작하는 모든 단어를 좀하고 싶습니다)

preg_match("/".$pattern."/i", remove_accents($word))) || ($common[$word] == 1) 
foreach($words['hilight'] as $change) { 
while (preg_match("~[^\>](".$change.")[^\<]~i", " ".$title." ", $regs)) { 
    $title = preg_replace("~".$regs[1]."~i", "<b>".$regs[1]."</b>", $title); 
} 
while (preg_match("~[^\>](".$change.")[^\<]~i", " ".$fulltxt." ", $regs)) { 
    $fulltxt = preg_replace("~".$regs[1]."~i", "<b>".$regs[1]."</b>", $fulltxt); 
} 
$url2 = $url; 
while (preg_match("~[^\>](".$change.")[^\<]~i", $url2, $regs)) { 
    $url2 = preg_replace("~".$regs[1]."~i", "<b>".$regs[1]."</b>", $url2); 
} 
} 

답변

0

문제에게 답장을

 $string="Put here string containing latin 5 characters"; 
     $changethis = array("I","ı","İ","ö","Ö","ü","Ü","ç","Ç","ş","Ş","ğ","Ğ"," ","\'","#","$","%","^","&","*","?"); 
     $tothis = array("i","i","_i","o","_o","u","_u","c","_c","s","_s","g","_g","","","","","","","","",""); 
     $newstring = str_replace($changethis, $tothis, "$string"); 
+0

감사를 해결하기 위해 PHP의 기능이 될 수 또 다른 대안을 않는 str_replace를 사용하여. 코드에서 볼 수 있듯이 "ç"가 "c"로 바꿉니 까? 이 경우 "ç" "c"와 "C"로 시작하는 모든 단어를 찾을 수 있습니까, 아니면 "c"로 시작하는 단어 만 찾을 수 있습니까? 두 번째 질문 : "_c"의 의미는 무엇입니까? – user1068000

+0

안녕하세요, 죄송합니다. 문자열의 모든 터키 문자를 바꿉니다. 예 : ç ~ c 또는 Ç ~ _c – mustafa