Skip to content

Instantly share code, notes, and snippets.

@reeslo
Forked from jrivero/new_slugify.php
Created December 14, 2017 10:33
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 reeslo/7dcade724635313b7de06c2138115439 to your computer and use it in GitHub Desktop.
Save reeslo/7dcade724635313b7de06c2138115439 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