Created
January 21, 2014 13:34
-
-
Save boffey/8540107 to your computer and use it in GitHub Desktop.
Revisions
-
boffey created this gist
Jan 21, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ function parameterize($string, $sep = '-') { # Get rid of anything thats not a valid letter, number, dash and underscore and # replace with a dash $paramterized_string = preg_replace("/[^a-z0-9\-_]/i", $sep, $string); # Remove connected dahses so we don't end up with -- anyhwere. $paramterized_string = preg_replace("/$sep{2,}/", $sep, $paramterized_string); # Remove any trailing spaces from the string $paramterized_string = preg_replace("/^$sep|$sep$/", '', $paramterized_string); # Downcase the string return strtolower($paramterized_string); }