Advertisement
eyuprog

Create Slug

Dec 25th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. function create_slug($text)
  2. {
  3.  
  4. $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
  5. $text = trim($text, '-');
  6. $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
  7. $text = strtolower($text);
  8. $text = preg_replace('~[^-\w]+~', '', $text);
  9.  
  10. if (empty($text))
  11. {
  12. return 'n-a';
  13. }
  14. return $text;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement