Skip to content

Instantly share code, notes, and snippets.

@fenric
Created March 6, 2017 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fenric/c7e5c75648861fa429b1670448cae1ed to your computer and use it in GitHub Desktop.
Save fenric/c7e5c75648861fa429b1670448cae1ed to your computer and use it in GitHub Desktop.
<?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