Wednesday, 2 October 2013

fputcsv() error with array

fputcsv() error with array

i tried to make a simple csv export with an easy array, but the server
tells me on every loop "fputcsv() expects parameter 2 to be array, string
given in"
Here is my Array:
"array(12) {
["gender"]=>
string(1) "1"
["first_name"]=>
string(6) "Daniel"
["last_name"]=>
string(5) "Weiß"
["street"]=>
string(12) "Langestrasse 1"
["plz"]=>
string(5) "45265"
["city"]=>
string(8) "Munich"
["country"]=>
string(3) "ger"
["tel"]=>
string(10) "0123456789"
["mobile"]=>
string(0) "0987654321"
["fax"]=>
string(0) ""
["email"]=>
string(8) "yo@lo.de"
["invest"]=>
string(1) "3"
}
Here is the very very simple code
// EXPORT
$fp = fopen('export.csv', 'w');
foreach( $form as $fields ) {
echo $fields;
fputcsv($fp, $fields, ';');
}
fclose($fp);

No comments:

Post a Comment