1 function seoUrl($string) {
2 //Lower case everything
3 $string = strtolower($string);
4 //Make alphanumeric (removes all other characters)
5 $string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
6 //Clean up multiple dashes or whitespaces
7 $string = preg_replace("/[\s-]+/", " ", $string);
8 //Convert whitespaces and underscore to dash
9 $string = preg_replace("/[\s_]/", "-", $string);
10 return $string;
11 }