Created
June 12, 2013 22:58
-
-
Save anunay/5769861 to your computer and use it in GitHub Desktop.
PHP 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 | |
function to_slug($string){ | |
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string))); | |
} | |
// Input: This is Headline | |
// Returns: this-is-headline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment