Skip to content

Instantly share code, notes, and snippets.

@supermethod
Created April 11, 2011 11:26
Show Gist options
  • Save supermethod/913379 to your computer and use it in GitHub Desktop.
Save supermethod/913379 to your computer and use it in GitHub Desktop.
String to Slug
function slug($str)
{
$str = strtolower(trim($str));
$str = preg_replace('/[^a-z0-9-]/', '-', $str);
$str = preg_replace('/-+/', "-", $str);
return $str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment