It is also possible to do this with str_replace, the first argument uses an array with accented characters and the second with the characters to be replaced.
$acentos = array('À', 'Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì',
'Í','Î','Ï','Ò','Ó','Ô','Õ','Ö','Ù','Ú','Û','Ü','Ý','à','á','â','ã','ä','å','ç','è'
,'é','ê','ë','ì','í','î','ï','ð','ò','ó','ô','õ','ö','ù','ú','û','ü','ý','ÿ', ' ');
$sem_acentos = array('A','A','A','A','A','A','C','E','E','E','E','I','I','I',
'I','O','O','O','O','O','U','U','U','U','Y','a','a','a','a','a','a','c','e','e','e'
,'e','i','i','i','i','o','o','o','o','o','o','u','u','u','u','y','y', '_');
$txtnome = 'AçÃO í è';
echo 'string original: '. $txtnome;
$txtnome = str_replace($acentos, $sem_acentos, $txtnome);
echo '<br> string: sem acentos'. $txtnome;
Example
These code cracks are typos.
– gmsantos
typos, as well as?
– akm
Look at the edition I made. your code is like this on your machine?
– gmsantos
Related: http://answall.com/questions/858/refatora%C3%A7%C3%A3o-de-fun%C3%A7%C3%A3o-para-remover-scor%C3%A7%C3%A3o-espa%C3%A7os-e-caracteres-especiais, http://answall.com/s/33029/like-remover-question-acento-no-upload-comphp.
– bfavaretto
Note: Actually the questions I indicated solve the same problem (remove accentuation), but only here we have answers that correct this specific code. So I chose to keep this open.
– bfavaretto