Clean URL String


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function get_clean_url_string($str) {
  2. $search = array(
  3. '/\s+/i',
  4. '/(-|_)(-|_)*/',
  5. '/[^a-z0-9_-]/i'
  6. );
  7. $replace = array(
  8. '-',
  9. '$1',
  10. ''
  11. );
  12. return preg_replace($search, $replace, trim($str));
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.