Remove accent in PHP (Ã) [duplicate]

1

I have the following function:

function tirarAcentos($string){
    return preg_replace(array("/(á|à|ã|â|ä)/","/(Á|À|Ã|Â|Ä)/","/(é|è|ê|ë)/","/(É|È|Ê|Ë)/","/(í|ì|î|ï)/","/(Í|Ì|Î|Ï)/","/(ó|ò|õ|ô|ö)/","/(Ó|Ò|Õ|Ô|Ö)/","/(ú|ù|û|ü)/","/(Ú|Ù|Û|Ü)/","/(ñ)/","/(Ñ)/","/(Ç)/","/(ç)/","/(Ã)/"),explode(" ","a A e E i I o O u U n N C c A"),$string);
}

However, when trying to remove an accent from "GPA - BREAD GROUP" I can not remove the Ã, in specific, I have tried everything and it does not remove.

How can I remove it?

Follow the application:

session_register("SESSION");
header("Cache-Control: no-cache");
include('Connect.php');
include('conf.php');
include('sec.php');

$v_conexao = new MySQL($vstr_usuario,$vstr_pass,$vstr_host,$vstr_db) or die ("Can't connect with the database");
$vint_conexao=$v_conexao->Get_Connection_ID();

$ssql = "SELECT nome FROM ang_cliente ORDER BY nome ASC";
$vint_result=$v_conexao->Open_Query($vint_conexao,$ssql);
while($v_a=$v_conexao->Fetch_Into($vint_result)){
    $nome_removido = tirarAcentos($v_a['nome']);
    echo "Nome Atual: ".$v_a['nome']."<br>";
    echo "Nome Atualizado: ".$nome_removido."<br>";
    echo "<hr>";
}
    
asked by anonymous 29.03.2017 / 15:28

1 answer

2

Using the iconv() function:

$text = "GPA - GRUPO PÃO DE ACUCAR";

setlocale(LC_CTYPE, 'pt_BR'); // Defines para pt-br
echo iconv('UTF-8', 'ASCII//TRANSLIT', $text);

What will you give:

GPA - GRUPO PAO DE ACUCAR

Works for all kinds of accents and if you want to know more about the function, just look here in the PHP - iconv ()

    
29.03.2017 / 15:59