Posted By

blubadger on 11/27/08


Tagged


Versions (?)

onlyreadables


 / Published in: PHP
 

  1. function onlyreadables($string) { // prend utf-8
  2. $string = utf8_decode($string);
  3. for ($i=0;$i<strlen($string);$i++) {
  4. $chr = $string{$i};
  5. $ord = ord($chr);
  6.  
  7. if ($ord>32 and $ord<126)
  8. continue;
  9. elseif ($ord>223 and $ord<230)
  10. $string{$i} = 'a';
  11. elseif ($ord>231 and $ord<236)
  12. $string{$i} = 'e';
  13. elseif ($ord>235 and $ord<240)
  14. $string{$i} = 'i';
  15. elseif ($ord>241 and $ord<247)
  16. $string{$i} = 'o';
  17. elseif ($ord>249 and $ord<253)
  18. $string{$i} = 'u';
  19. else
  20. $string{$i} = '.';
  21. }
  22. return $string;
  23. }

Report this snippet  

You need to login to post a comment.