davidck
(Davidck)
1
Hi, is there a built-in Yii function to "beautify" a string to use as part of an urlencode URL?
For example:
/this+is+an+example+%26amp%3B+I’m+stumped.
TO
/this-is-an-example-and-i-am-stumped
It doesn’t have to be that smart, even if it doesn’t translate & to and, or I’m to i-am, it’s fine as long as I don’t see weird characters on the URL.
Thanks!
I don’t think there is, but feel free to use mine
function prettyUrl($input)
{
if (Yii::app()->getLanguage()=='de')
{
$input = preg_replace('/&(.)uml;/', "$1e", htmlentities(utf8_decode($input)));
}
$fURL = preg_replace('/&(.)(acute|cedil|circ|ring|tilde|uml);/', "$1", htmlentities(utf8_decode($input)));
$fURL = preg_replace('/&#(\d+);/', '', $fURL);
$fURL = preg_replace('/([^a-z0-9]+)/', '-', strtolower(html_entity_decode($fURL)));
$fURL = trim($fURL, '-');
return $fURL;
}