Last active
August 29, 2015 14:01
-
-
Save ashby/dc69b605df3de2836a2b to your computer and use it in GitHub Desktop.
PHP: Prep ID/URL
This file contains hidden or 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 prepID($string) { | |
$string = strtolower($string); | |
$string = preg_replace("/[^a-z0-9_\s-]/", "", $string); | |
$string = preg_replace("/[\s-]+/", " ", $string); | |
$string = preg_replace("/[\s_]/", "-", $string); | |
return $string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment