Posted By

prf_q on 01/14/09


Tagged

php replace filter chars special characters accents


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

umang_nine
dsntos
vali29
huynguye


Replace All Latin Accents


 / Published in: PHP
 

// FUNCION BY Ahmet Alp Balkan // http://www.ahmetalpbalkan.com

  1. <?php
  2.  
  3. // FUNCION BY Ahmet Alp Balkan
  4. // http://www.ahmetalpbalkan.com
  5.  
  6. function replaceAccents($newphrase){
  7.  
  8. $newphrase = str_replace("Ü","U",$newphrase);
  9. $newphrase = str_replace("Ã…Â?","S",$newphrase);
  10. $newphrase = str_replace("�","G",$newphrase);
  11. $newphrase = str_replace("Ç","C",$newphrase);
  12. $newphrase = str_replace("Ä°","I",$newphrase);
  13. $newphrase = str_replace("Ö","O",$newphrase);
  14. $newphrase = str_replace("ü","u",$newphrase);
  15. $newphrase = str_replace("ÅŸ","s",$newphrase);
  16. $newphrase = str_replace("ç","c",$newphrase);
  17. $newphrase = str_replace("ı","i",$newphrase);
  18. $newphrase = str_replace("ö","o",$newphrase);
  19. $newphrase = str_replace("ÄŸ","g",$newphrase);
  20.  
  21. $newphrase = str_replace("Ü","U",$newphrase);
  22. $newphrase = str_replace("Å?","S",$newphrase);
  23. $newphrase = str_replace("Ä?","G",$newphrase);
  24. $newphrase = str_replace("Ç","C",$newphrase);
  25. $newphrase = str_replace("Ä°","I",$newphrase);
  26. $newphrase = str_replace("Ö","O",$newphrase);
  27. $newphrase = str_replace("ü","u",$newphrase);
  28. $newphrase = str_replace("ÅŸ","s",$newphrase);
  29. $newphrase = str_replace("ç","c",$newphrase);
  30. $newphrase = str_replace("ı","i",$newphrase);
  31. $newphrase = str_replace("ö","o",$newphrase);
  32. $newphrase = str_replace("ÄŸ","g",$newphrase);
  33.  
  34.  
  35. $newphrase = str_replace("Ü","U",$newphrase);
  36. $newphrase = str_replace("Ğ","G",$newphrase);
  37. $newphrase = str_replace("Ş","S",$newphrase);
  38. $newphrase = str_replace("İ","I",$newphrase);
  39. $newphrase = str_replace("Ö","O",$newphrase);
  40. $newphrase = str_replace("Ç","C",$newphrase);
  41. $newphrase = str_replace("ü","u",$newphrase);
  42. $newphrase = str_replace("ğ","g",$newphrase);
  43. $newphrase = str_replace("ş","s",$newphrase);
  44. $newphrase = str_replace("ı","i",$newphrase);
  45. $newphrase = str_replace("ö","o",$newphrase);
  46. $newphrase = str_replace("ç","c",$newphrase);
  47.  
  48.  
  49. $newphrase = str_replace("Ù","U",$newphrase);
  50. $newphrase = str_replace("Ğ","G",$newphrase);
  51. $newphrase = str_replace("Ş","S",$newphrase);
  52. $newphrase = str_replace("İ","I",$newphrase);
  53. $newphrase = str_replace("Ö","O",$newphrase);
  54. $newphrase = str_replace("Ç","C",$newphrase);
  55. $newphrase = str_replace("ü","u",$newphrase);
  56. $newphrase = str_replace("ğ","g",$newphrase);
  57. $newphrase = str_replace("ş","s",$newphrase);
  58. $newphrase = str_replace("ı","i",$newphrase);
  59. $newphrase = str_replace("ö","o",$newphrase);
  60. $newphrase = str_replace("ç","c",$newphrase);
  61.  
  62. $newphrase = str_replace("%u015F","s",$newphrase);
  63. $newphrase = str_replace("%E7","c",$newphrase);
  64. $newphrase = str_replace("%FC","u",$newphrase);
  65. $newphrase = str_replace("%u0131","i",$newphrase);
  66. $newphrase = str_replace("%F6","o",$newphrase);
  67. $newphrase = str_replace("%u015E","S",$newphrase);
  68. $newphrase = str_replace("%C7","C",$newphrase);
  69. $newphrase = str_replace("%DC","U",$newphrase);
  70. $newphrase = str_replace("%D6","O",$newphrase);
  71. $newphrase = str_replace("%u0130","I",$newphrase);
  72. $newphrase = str_replace("%u011F","g",$newphrase);
  73. $newphrase = str_replace("%u011E","G",$newphrase);
  74.  
  75. $newphrase = str_replace("£","E",$newphrase);
  76. $newphrase = str_replace("é","e",$newphrase);
  77. $newphrase = str_replace("è","e",$newphrase);
  78. $newphrase = str_replace("ß","x",$newphrase);
  79.  
  80. $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ';
  81. $b = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr';
  82. $newphrase = utf8_decode($newphrase);
  83. $newphrase = strtr($newphrase, utf8_decode($a), $b);
  84.  
  85.  
  86.  
  87.  
  88. $newphrase = strtr($newphrase, "à âäçéèêëîïôöûü","aaaceeeeiioouu");
  89.  
  90. return $newphrase;
  91. }
  92. ?>

Report this snippet  

You need to login to post a comment.