I convert any special characters to dashes in my string except for alphanumerics using this:
return preg_replace("![^a-z0-9]+!i", "-", $str);
However, in some case I have this strings:
$str = "Hello there chubby!";
which will result to:
Hello-there-chubby-
The dash on the end of word is what makes me think of a solution on how to remove that.