- Code: Select all
function show_csv_using_fgetcsv($csv_file)
{
if (($handle = fopen($csv_file, "r")) !== FALSE) {
while (($ary = fgetcsv($handle, 0, ',')) !== FALSE) {
print_r($ary);
}
fclose($handle);
}
}
Sample CSV in file (UTF-8, no BOM):
- Code: Select all
1,"会","a"
2,"―","a"
instead of giving me
- Code: Select all
[0] => Array
(
[0] => 1
[1] => 会
[2] => a
)
[1] => Array
(
[0] => 2
[1] => ―
[2] => a
)
it gives
- Code: Select all
[0] => Array
(
[0] => 1
[1] => 会",a"
)
[1] => Array
(
[0] => 2
[1] => ―",a"
)
Only some characters cause the error, 会 and ― are the two of them.
It's noted only in CLI php.exe but not in browser.
Is it a known PHP 7 bug or version problem?
I did not have this back in PHP 5.2