Created
March 6, 2017 08:10
-
-
Save fenric/c7e5c75648861fa429b1670448cae1ed to your computer and use it in GitHub Desktop.
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 slug($rawString) | |
{ | |
$stringSluggable = $rawString; | |
$stringSluggable = transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', $stringSluggable); | |
$stringSluggable = preg_replace(['/[^a-z0-9-]/', '/-+/'], '-', $stringSluggable); | |
$stringSluggable = trim($stringSluggable, '-'); | |
return $stringSluggable; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment