0

In PHP, I am trying to create an array from a CSV file in this way.

// CSV file:
$csv = array_map('str_getcsv', file("{$uploadPath}/{$myFile}"));

Of course it is working for me, but on thing I have to fixed. If I have non-English language characters in my CSV file, then those characters not showing correctly in PHP. That mean its showing question marks instead of showing original characters.

This is the output of $csv array:

Array
(
    [0] => Array
        (
            [0] => SISP-0002
            [1] => Harpic Floral 500ml
            [2] => ???????? ??????? 500ml 
            [3] => 4792037107765
        )
)

UPDATE:

I have set charset inside page tag as shown here.

<meta charset="utf-8">

And also I have saved my CSV file with unicode(UTF-8)

Can anybody tell me what would be the possible workaround to fix this issue.

user3733831
  • 2,886
  • 9
  • 36
  • 68

1 Answers1

0

This appears to be the definitive question and answers for UTF-8 and php UTF-8 all the way through

JGNI
  • 3,933
  • 11
  • 21