0

i try to take data from an array but it doesn't recognize the acents.

public function model(array $row)
{

    return new Dato([
        'name'     => $row['nombre_completo'],
        'pedido'        => $row['curso_de_interes'], 
        'hora_contacto'  => $row['horario_de_contacto'],
        'email'    => $row['correo_electrónico'], 
        'telefono'     => $row['número_de_teléfono'],

    ]);
}

the data came from a csv archive, the problem is in $row['correo_electrónico'] and $row['número_de_teléfono']. It doesn recognize de acents.

I try to use "correo_electr\u00f3nico" instead of "correo_electrónico" but still failing

UPDATE

i just ignore de acents, and it work fine

i use "correo_electronico" instead of "correo_electrónico"

thanks alot

  • [this](https://stackoverflow.com/questions/3371697/replacing-accented-characters-php/3373364#3373364) might help. – jibsteroos Jun 25 '20 at 21:06

1 Answers1

0

that looks like an encoding issue, you need to figure out what encoding you are using in your code and what is used in the row indexes. Then you have to convert the encoding to match your need.

try

foreach($row as $key => $value) echo $key . ' is encoded as ' . mb_detect_encoding($key) . " <BR>\n";
echo 'your code is encoded as ' . mb_detect_encoding('número_de_teléfono');

if mb_detect_encoding() doesn't work you can try with iconv_get_encoding()

then you can convert the encoding to what you need mb_convert_encoding() or iconv()

Nathanael
  • 870
  • 5
  • 11