Skip to content

Instantly share code, notes, and snippets.

@eduardo-matos
Created December 26, 2013 11:03
Show Gist options
  • Select an option

  • Save eduardo-matos/8132329 to your computer and use it in GitHub Desktop.

Select an option

Save eduardo-matos/8132329 to your computer and use it in GitHub Desktop.
Troca caracteres acentuados por seus equivalentes não acentuados.
<?php
function replace_accents($string)
{
return str_replace( array('à','á','â','ã','ä', 'ç', 'è','é','ê','ë', 'ì','í','î','ï', 'ñ', 'ò','ó','ô','õ','ö', 'ù','ú','û','ü', 'ý','ÿ', 'À','Á','Â','Ã','Ä', 'Ç', 'È','É','Ê','Ë', 'Ì','Í','Î','Ï', 'Ñ', 'Ò','Ó','Ô','Õ','Ö', 'Ù','Ú','Û','Ü', 'Ý'), array('a','a','a','a','a', 'c', 'e','e','e','e', 'i','i','i','i', 'n', 'o','o','o','o','o', 'u','u','u','u', 'y','y', 'A','A','A','A','A', 'C', 'E','E','E','E', 'I','I','I','I', 'N', 'O','O','O','O','O', 'U','U','U','U', 'Y'), $string);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment