Posted By

antti on 09/29/10


Tagged

php format textmate safe transform netsafe


Versions (?)

Make text net safe


 / Published in: Other
 

  1. function makeInternetSafe($text) {
  2.  
  3. $text = stripslashes($text);
  4. $text = mb_strtolower($text, 'utf-8');
  5.  
  6. $forbidden = array('Ä', 'Ö', 'Å', 'ä', 'ö', 'å', ' ', '#');
  7. $replace = array('A', 'O', 'a', 'a', 'o', 'a', '_', '-');
  8. $text = str_replace($forbidden, $replace, $text);
  9.  
  10. $text = preg_replace('#[^a-z0-9._-]#', '', $text);
  11.  
  12. return $text;
  13. }

Report this snippet  

You need to login to post a comment.