1

I read a csv file with php and print it to the screen with echo.

After printing, there is a utf-8 character problem in the output.

how can i solve this problem?

enter image description here

    <?php
$row = 1;
if (($handle = fopen("Liste.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        echo "<p> $row satırındaki $num alan: <br /></p>\n";
        $row++;
        for ($c=0; $c < $num; $c++) {
            echo $data[$c] . "<br />\n";
        }
     }
    fclose($handle);
 }


// convert encoding
$data = mb_convert_encoding($data, "UTF-8", "auto");

// str_getcsv
$array = str_getcsv($data);

?>
Jagger
  • 37
  • 2
  • 1. Never try to autodetect encodings, it will _never_ work reliably. You must always explicitly know what your input encoding is. 2. https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Sammitch Sep 24 '21 at 16:52

0 Answers0