Skip to content

Instantly share code, notes, and snippets.

@NicolasPio
Created July 22, 2015 18:22
Show Gist options
  • Save NicolasPio/bb26f74237563c81b34f to your computer and use it in GitHub Desktop.
Save NicolasPio/bb26f74237563c81b34f to your computer and use it in GitHub Desktop.
public function getSlug($slug)
{
$slug = preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($slug, ENT_QUOTES, 'UTF-8'));
$slug = preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode($slug, ENT_QUOTES, 'UTF-8'));
$slug = strtolower( trim($slug, '-') );
return $slug;
}
@plastic
Copy link

plastic commented Aug 3, 2015

POG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment