Created
July 26, 2013 18:30
-
-
Save doitlikejustin/6091140 to your computer and use it in GitHub Desktop.
Convert 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
<?php | |
// will convert "Hello World!" to "hello-world" | |
function to_slug($string) | |
{ | |
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string))); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment