Here's mine:
PHP Code:
/**
* Create URL Title
*
* Takes a "title" string as input and creates a
* human-friendly URL string with either a dash
* or an underscore as the word separator.
*
* @access public
* @param string the title
* @param string the separator
* @return string
*/
function url_title($str, $separator = '-')
{
$trans = array(
'\s+' => $separator,
'[^a-z0-9'.$separator.']' => '',
$separator.'+' => $separator,
$separator.'$' => '',
'^'.$separator => ''
);
$str = strtolower($str);
foreach ($trans as $search => $replace)
{
$str = preg_replace('#'.$search.'#', $replace, $str);
}
return $str;
}
Bookmarks