Posted By

section31 on 09/16/08


Tagged

clean urls


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

jdstraughan
luman
ithinksometimes
vali29


Clean URL String


 / Published in: PHP
 

  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  

You need to login to post a comment.