Created
July 11, 2012 14:08
-
-
Save loranger/3090581 to your computer and use it in GitHub Desktop.
Slugify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function slugify($string) | |
{ | |
$replacement = array( | |
'/&([a-z])(acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);/i' => '$1', | |
'/\s/i' => '_', | |
'/\W/i' => '' | |
); | |
return preg_replace(array_keys($replacement), array_values($replacement), htmlentities($string, ENT_NOQUOTES, 'utf-8')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment