Created
April 11, 2011 11:26
-
-
Save supermethod/913379 to your computer and use it in GitHub Desktop.
String to Slug
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
function slug($str) | |
{ | |
$str = strtolower(trim($str)); | |
$str = preg_replace('/[^a-z0-9-]/', '-', $str); | |
$str = preg_replace('/-+/', "-", $str); | |
return $str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment