Hi
i have this function which generates a seo friendly url from a string :
function seo_titleinurl_generate($title)
{
$title=substr($title,0,160);
$title = ereg_replace(" ", "-", $title); // replace spaces by "-"
$title = ereg_replace("á", "a", $title); // replace special chars
$title = ereg_replace("í", "i", $title); // replace special chars
$title = ereg_replace("ó", "o", $title); // replace special chars
$title = ereg_replace("ú", "u", $title); // replace special chars
$title = ereg_replace("ñ", "n", $title); // replace special chars
$title = ereg_replace("Ñ", "n", $title); // replace special chars
$title = strtolower(trim($title)); // lowercase
$title = preg_replace("/([^a-zA-Z0-9_-])/",'',$title); // only keep standard latin letters and numbers, hyphens and dashes
if($title=="" or $title=="-"){
$mr=rand(1,99999);
$mt=time();
$title=$mr.$mt;
}
return $title;
}
But in some cases when the string has multiple spaces like : the most (3 spaces here)
nice pranks!
it's generates : the-most---nice-pranks
i want it to ignore many spaces and make them only one dash.
Thanks