Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://gist.github.com/tlongren/5527129
- setlocale(LC_ALL, 'en_US.UTF8');
- function slug_url($str, $delimiter='-') {
- $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
- $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
- $clean = strtolower(trim($clean, '-'));
- $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
- return $clean;
- }
- echo slug_url("Qu'en est-il français? Ça marche alors?");
- // return: quen-est-il-francais-ca-marche-alors
Advertisement
Add Comment
Please, Sign In to add comment