Skip to content

Instantly share code, notes, and snippets.

@jrivero
Created February 19, 2016 00:16
Show Gist options
  • Save jrivero/6ef6eae0a75ad17fee58 to your computer and use it in GitHub Desktop.
Save jrivero/6ef6eae0a75ad17fee58 to your computer and use it in GitHub Desktop.
<?php
function slugify($string) {
$string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string);
$string = preg_replace('/[-\s]+/', '-', $string);
return trim($string, '-');
}
echo slugify("Я люблю PHP!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment