Posted By

fetolio on 09/19/09


Tagged

url generator uri address


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

fetolio
kernelpanics


String to URL generator - impoved


 / Published in: PHP
 

URL: http://snipplr.com/view.php?codeview&id=9024

I've made some changes

  1. function tourl($strText) {
  2. $strText = preg_replace('/ã|â|á|ä|à/i','a',$strText);
  3. $strText = preg_replace('/ê|é|ë|è/i','e',$strText);
  4. $strText = preg_replace('/î|í|ï|ì/i','i',$strText);
  5. $strText = preg_replace('/õ|ô|ó|ö|ò/i','o',$strText);
  6. $strText = preg_replace('/û|ú|ü|ù/i','u',$strText);
  7. $strText = str_ireplace(array('ç','ñ'),array('c','n'),$strText);
  8. $strText = preg_replace('/[^A-Za-z0-9-]/', ' ', $strText);
  9. $strText = preg_replace('/ +/', ' ', $strText);
  10. $strText = trim($strText);
  11. $strText = str_replace(' ', '-', $strText);
  12. $strText = preg_replace('/-+/', '-', $strText);
  13. $strText = strtolower($strText);
  14. return $strText;
  15. }

Report this snippet  

You need to login to post a comment.