PHP SEO URL Function

An update of previous function from archive. Usage is very simple...

echo seo("give me some ćevapčići"); // give-me-some-cevapcici

function seo($input){
    $input = mb_convert_case($input, MB_CASE_LOWER, "UTF-8"); //convert UTF-8 string to lowercase
    $a = array('č','ć','ž','đ','š');
    $b = array('c','c','z','dj','s');
    //$input = strtr($input, "čćžđšè", "cczdse"); not working properly :(
    $input = preg_replace("/[^a-zA-Z0-9]+/", "-", $input); //replace all non alphanumeric chars with dashes
    $input = preg_replace("/(-){2,}/", "$1", $input); //prevent repeating dashes
    $input = trim($input, "-"); //trim dashes both sides, if any
    return $input; //voila
}


If you need any help please write your question in comments.
©2009-2011 Webarto • web design & development • Tuzla // Sarajevo // Beograd