Beautify a single URL token.

Hi, is there a built-in Yii function to "beautify" a string to use as part of an urlencode URL?

For example:




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.


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;


Nice, thanks!

Check urldecode, too.