This is another PHP sef function, much better to use in case you want to get remove characters that are not a-z, 0-9, dash, underscore or space, then remove all leading and trailing spaces, change all dashes, underscores and spaces to dashes and return the modified string in lower case.
PHP search engine friendly url function
-
function sef($string)
-
{
-
// remove all characters that aren’t a-z, 0-9, dash, underscore or space
-
$not_acceptable_characters = '#[^-a-zA-Z0-9_ ]#';
-
$string = preg_replace($not_acceptable_characters, '', $string);
-
// remove all leading and trailing spaces
-
$string = trim($string);
-
// change all dashes, underscores and spaces to dashes
-
$string = preg_replace('#[-_ ]+#', '-', $string);
-
// return the modified string
-
return strtolower($string);
-
}