String to URL generator - impoved


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

I've made some changes


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.