note 100168 added to function.fgetcsv
| From: | Xander at osu1 dot php dot net | Date: | Wed, 29 Sep 2010 08:42:01 +0000 |
| Subject: | note 100168 added to function.fgetcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172802@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:
$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.
----
Server IP: 69.147.83.197
Probable Submitter: 83.27.70.155
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit -- https://master.php.net/note/edit/100168
Del: integrated -- https://master.php.net/note/delete/100168/integrated
Del: useless -- https://master.php.net/note/delete/100168/useless
Del: bad code -- https://master.php.net/note/delete/100168/bad+code
Del: spam -- https://master.php.net/note/delete/100168/spam
Del: non-english -- https://master.php.net/note/delete/100168/non-english
Del: in docs -- https://master.php.net/note/delete/100168/in+docs
Del: other reasons-- https://master.php.net/note/delete/100168
Reject -- https://master.php.net/note/reject/100168
Search -- https://master.php.net/manage/user-notes.php