1
I use a function to replace characters with accents or special characters, but when using the same function with data from MySQL
the function is not replacing the characters.
Assuming the city is Foz do Iguaçu
, the function would return: Foz do Iguacu
, Hence, the c would be replaced by c.
In the Mysql database structure the city is:
type = varchar (80)
Collation = latin1_general_ci
$cidade=removeAcentos($row['cli_cidade'])
function removeAcentos ($string){
// REMOVENDO ACENTOS
$tr = strtr($string,
array (
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A',
'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E',
'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ð' => 'D', 'Ñ' => 'N',
'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O',
'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Ŕ' => 'R',
'Þ' => 's', 'ß' => 'B', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a',
'ä' => 'a', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e',
'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i',
'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o',
'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y',
'þ' => 'b', 'ÿ' => 'y', 'ŕ' => 'r', 'º' => '', 'ª' => ''
)
);
return $tr;
}
Have you tried
$cidade=removeAcentos(utf8_encode($row['cli_cidade']))
?– KaduAmaral
It didn’t work, I tried to force ((string) ($Row['cli_cidade'])) but it didn’t work either. @Kaduamaral
– Adrianoecris