Validation in_array with Ç

0

I have an array:

$enderecos  = array( 'Endereço', 'Endereco', 'Endereço ' );

I use the fgetcsv function to read my CSV, I check the csv header by comparing if the header is included in the array.

    if(in_array($colunas_csv, $enderecos))
    {
        $endereco_posicao = $key;
    }

Where $colunas_csv is the return of the header, what happens is that if the returned header is Endereco the check occurs, but if Endereço does not occur, due to Ç .

    
asked by anonymous 28.11.2017 / 16:10

1 answer

0

You can build on this example:

<?php
        $arr = ["Endereco","Endereço","Não", "Olá"];
        $decode = implode(' ', $arr);
        $Format = array();
        $Format['a'] = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜüÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿRr"!@#$%&*()_-+={[}]/?;:.,\\'<>°ºª'; //Pega tudo que tiver acento
        $Format['b'] = 'aaaaaaaceeeeiiiidnoooooouuuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr                                 '; //Todos os itens do Format['b'] vão ser substituidos por esses
        $Data = strtr(utf8_decode($decode), utf8_decode($Format['a']), utf8_decode($Format['b'])); //Faz a substituição
        $Final = trim(strip_tags($Data)); //Limpa a string de espaços iniciais e finais e de codigos html/JS/PHP
        echo $Final;

?>

What will be printed: Endereco Endereco Nao Ola

I tried to explain with comments to make it easier to understand.

    
28.11.2017 / 16:26