Skip to content

Instantly share code, notes, and snippets.

@bogomolov-dev
Last active December 28, 2015 18:09
Show Gist options
  • Save bogomolov-dev/7541237 to your computer and use it in GitHub Desktop.
Save bogomolov-dev/7541237 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment