note 123807 added to function.fputcsv
| From: | mnz@php.net | Date: | Tue, 30 Apr 2019 09:25:42 +0000 |
| Subject: | note 123807 added to function.fputcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210872@lists.php.net to get a copy of this message | ||
Hope this could help..
In some server configuration an associative array doesn't work. In my case the script stops
without any error or message, just fputcsv return "false".
Diggin'n'Debuggin I found that in my local setup associative arrays works, but on live
server not. Just removing keys solved the problem.
So, it's better to strip keys before calling fputcsv()
<?php
// Remove keys from an array
$csv_fields = array();
foreach($associative_array as $value) {
$csv_fields[] = $value;
}
fputcsv( $handler, $csv_fields);
?>
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.142 (proxied: 37.183.8.30)
----
Manual Page -- http://php.net/manual/en/function.fputcsv.php
Edit -- https://master.php.net/note/edit/123807
Del: integrated -- https://master.php.net/note/delete/123807/integrated
Del: useless -- https://master.php.net/note/delete/123807/useless
Del: bad code -- https://master.php.net/note/delete/123807/bad+code
Del: spam -- https://master.php.net/note/delete/123807/spam
Del: non-english -- https://master.php.net/note/delete/123807/non-english
Del: in docs -- https://master.php.net/note/delete/123807/in+docs
Del: other reasons-- https://master.php.net/note/delete/123807
Reject -- https://master.php.net/note/reject/123807
Search -- https://master.php.net/manage/user-notes.php