$data = [
[1,'Deng','php'],
[1,'Deng','html'],
[1,'Deng','css' ]
];
foreach ($data as $v){
fputcsv($file,$v);
}
print_r(fgetcsv($file));
There is no problem with the code and the written csv file, but the format of the printed array is wrong.
Finally find out, Deng. Just change it to English. What's the answer? Doesn’t it support Chinese writing?
fgetcsv is sensitive to locale settings. For example, if LANG is set to en_US.UTF-8, single-byte encoded files will have read errors.
setlocale(LC_ALL, 'zh_CN'); Set Simplified Chinese
Then check the csv file encoding problem, open the csv with Notepad, the encoding setting is consistent with the server, such as utf8