Created
July 27, 2016 18:38
-
-
Save rbk/2db1e18046359cdb1f4a75be21f2d230 to your computer and use it in GitHub Desktop.
Slugify
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 slugify( $str ) { | |
$new_str = $str; | |
$new_str = preg_replace('/ /', '-', $new_str); | |
$new_str = preg_replace('/[^A-Za-z0-9\-]/', '', $new_str); | |
$new_str = strtolower($new_str); | |
return $new_str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment