alexander-bogomolov
11/19/2013 - 6:43 AM

slugify.inc

public static function slugify($text)
{
  $search = array('ö', 'ä', 'ü', 'ß');
  $replace = array('oe', 'ae', 'ue', 'ss');

  // replace german letters
  $text = str_replace($search, $replace, strtolower($text));

  // replace all non letters or digits by -
  $text = preg_replace('/\W+/', '-', $text);

  // trim and lowercase
  $text = strtolower(trim($text, '-'));

  return $text;
}