UTF-8 problems while reading CSV file with fgetcsv

前端 未结 6 1268
[愿得一人]
[愿得一人] 2020-12-02 22:45

I try to read a CSV and echo the content. But the content displays the characters wrong.

Mäx Müstermänn -> Mäx Müstermänn

Encoding of the CSV file is UT

6条回答
  •  臣服心动
    2020-12-02 23:30

    Try this:

    First nameLast name';
    while ($data = fgetcsv ($handle, 1000, ";")) {
            $data = array_map("utf8_encode", $data); //added
            $num = count ($data);
            for ($c=0; $c < $num; $c++) {
                // output data
                echo "$data[$c]";
            }
            echo "";
    }
    ?>
    

提交回复
热议问题