note 100168 modified in function.fgetcsv by danbrown
| From: | danbrown@php.net | Date: | Wed, 29 Sep 2010 16:58:50 +0000 |
| Subject: | note 100168 modified in function.fgetcsv by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172817@lists.php.net to get a copy of this message | ||
I had a problem with multibytes. File was windows-1250, script was UTF-8 and set_locale wasn't
work so I made a simple and safe workaround:
<?php
$fc = iconv('windows-1250', 'utf-8',
file_get_contents($_FILES['csv']['tmp_name']));
file_put_contents('tmp/import.tmp', $fc);
$handle = fopen('tmp/import.tmp', "r");
$rows = array();
while (($data = fgetcsv($handle, 0, ";")) !== FALSE) {
$rows[] = $data;
}
fclose($handle);
unlink('tmp/import.tmp');
?>
I hope You will find it out usefull.
Sorry for my english.
--was--
I had a problem with multibytes. File was windows-1250, script was UTF-8 and set_locale wasn't
work so I made a simple and safe workaround:
$fc = iconv('windows-1250', 'utf-8',
file_get_contents($_FILES['csv']['tmp_name']));
file_put_contents('tmp/import.tmp', $fc);
$handle = fopen('tmp/import.tmp', "r");
$rows = array();
while (($data = fgetcsv($handle, 0, ";")) !== FALSE) {
$rows[] = $data;
}
fclose($handle);
unlink('tmp/import.tmp');
I hope You will find it out usefull.
Sorry for my english.
http://php.net/manual/en/function.fgetcsv.php