Last active
December 28, 2015 18:09
-
-
Save bogomolov-dev/7541237 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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