Skip to content

Instantly share code, notes, and snippets.

@jordanmaslyn
Forked from hmert/slug.php
Created June 1, 2012 20:20
Show Gist options
  • Save jordanmaslyn/2854905 to your computer and use it in GitHub Desktop.
Save jordanmaslyn/2854905 to your computer and use it in GitHub Desktop.
PHP: Create Slug Function
function create_slug($string){
$string = preg_replace( '/[«»""!?,.!@£$%^&*{};:()]+/', '', $string );
$string = strtolower($string);
$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
return $slug;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment