Here is the function I have been using to make friendly url strings.
The second param is your spacer.
function makeURLFriendly($string,$spacer = "-") { $newstring = strtolower($string); $newstring = preg_replace('/[^a-zA-Zds]+/s', '', $newstring); $newstring = preg_replace('/ss+/', ' ', $newstring); $newstring = str_replace(' ', $spacer, $newstring ); return $newstring; }