2012-06-25 1 views
0

을 (를) 재정의했습니다. 게시물의 제목에서 URL 슬러그를 만들려면 위의 함수가 있습니다. 문제는 ç 문자가 c으로 변환되지 않는 것입니다. 실제로 함수에 의해 대체되고 있습니다.슬러그 URL 생성 기능이 Ç

예 포스트 제목 : Coração 드 Pelúcia

는 슬러그 생성 : coraao 드 pelucia

나는 등 슬러그 생성하기 위해이 함수를 해결할 수있는 방법 coracao 드 pelucia을

function generate_seo_link($input,$replace = '-',$remove_words = true,$words_array = array()) 
{ 
    //make it lowercase, remove punctuation, remove multiple/leading/ending spaces 
    $return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input)))); 

    //remove words, if not helpful to seo 
    //i like my defaults list in remove_words(), so I wont pass that array 
    if($remove_words) { $return = remove_words($return,$replace,$words_array); } 

    //convert the spaces to whatever the user wants 
    //usually a dash or underscore.. 
    //...then return the value. 
    return str_replace(' ',$replace,$return); 
} 

답변

2

변환을 위해 iconv 모듈과이 함수를 사용해야합니다.

function url_safe($string){ 
    $url = $string; 
    setlocale(LC_ALL, 'pt_BR'); // change to the one of your language 
    $url = iconv("UTF-8", "ASCII//TRANSLIT", $url); 
    $url = preg_replace('~[^\\pL0-9_]+~u', '-', $url); 
    $url = trim($url, "-"); 
    $url = strtolower($url); 
    return $url; 
} 
+0

잘 작동합니다. 고맙습니다. –