fputcsv is a PHP function that formats a line (passed as a fields array) as CSV and writes it (terminated by a newline) to the specified file handle. `fputcsv` support started with PHP version 5.1.0.
Questions tagged [fputcsv]
354 questions
-1
votes
1 answer
fputcsv via js post call not downloading
I am trying to make a JS link POST to another php file to cause a csv download. Everything is happening correctly - except for the csv download. I can see the csv data in DevTools in chrome, but the csv is not downloading.
The link has target…

PatrickNY
- 153
- 1
- 10
-1
votes
1 answer
fputcsv and fgetcsv
My code looks like this .. the o/p is a csv file with 4 values in ONE cell and so on in the FIRST column alone
Better versions of this code please . ASAP
foreach ($xml->xyz as $xyz) {
$f = fopen('blahblahblah.csv', 'a') or die("can't open…

Zac
- 695
- 1
- 11
- 34
-1
votes
4 answers
How to save a single column from a multidimensional array as a .csv file?
The following code exports the whole array into the .csv file, but I only want to export a specific column.

gaurav chhabra
- 11
- 3
-1
votes
1 answer
PHP, Writing to CSV not on same line?
function writePlayerInfo($playerFName, $playerSName, $phone, $email){
$data = array();
array_push($data, $playerFName, $playerSName, $phone, $email);
$handleName = fopen("data/names.csv","w");
foreach ($data as $line)
{
…

mattoakley
- 11
- 3
-1
votes
1 answer
How to avoid unnecessary double quotation (") in fputcsv?
I am going to export an output of a query in a text file (not CSV file) via PHP using fputcsv function, but when I open the text file, extra double-quotes (") are added at the start & end, and also in the middle:
"SET: NEID=35;"
"ADD…

Meena
- 55
- 7
-1
votes
1 answer
php fputcsv not working
I do not understand why my fputcsv is not working. Here is what I've got:
prepare('SELECT QName, tsql from…

Mike
- 1,853
- 3
- 45
- 75
-1
votes
1 answer
write CSV with fputcsv
When I use this code, the new CVS file get "" by text with blanks:
//array in csv schreiben
$daten = array_filter($daten);
$csv_array[] = $daten;
$fp = fopen("golfDBtest.csv", 'w');
foreach ($csv_array as $fields) {
fputcsv($fp,…

wolli911
- 7
- 5
-1
votes
1 answer
fputcsv adds unwanted Validation comment at top of file
I need csv output with column headers and comma delimited data. The fputcsv function is working right except that it places a "Validation" comment at the top of the output file:
This line causes the file…

parboy
- 67
- 8
-1
votes
3 answers
Array push rows from SQL query
I am trying to save the rows (results) from an SQL query to a csv file.
I am using array push in order to put the results in a list. Later I put the data from this list to my csv file.
My code :
while ($row = $query->fetch_assoc())
{
…

Datacrawler
- 2,780
- 8
- 46
- 100
-1
votes
1 answer
Export Json Array to CSV in php
I have this array of provider
[
{
"reference":"01042",
"images": [
"http:\/\/static1.provider.com\/34\/01042.jpg"
]
},
{
"reference":"01057",
"images":[
…

Juanjo
- 43
- 4
-1
votes
2 answers
How to edit (replacing would be fine) a row in a .csv file using php?
So I've looked at fputcsv but it seems to replace the whole file. Is there a way that a I can replace or edit a particular row in a CSV file using PHP? I do NOT want to upload (as an array or some other data structure) the entire CSV edit the upload…

Bren
- 3,516
- 11
- 41
- 73
-1
votes
1 answer
Move pointer horizontally using fputcsv in PHP
I am trying to write 2 arrays to csv file using fputcsv.
But the problem is when writing the second array it goes to the end of the file and starts from there.
So basically I have these 2 sections to write in a csv file and it's writing in the…

Raj
- 1,377
- 6
- 23
- 48
-1
votes
1 answer
How To Add serial Number Column And Serial Numbers In That In fputcsv in PHP
I am using fputcsv to export my database into the excel format. Currently it is showing all fields, including the id from the database. But I want Serial Numbers in the first column of the exported CSV file. The Database id series may change if some…

chplab
- 49
- 8
-1
votes
1 answer
Convert 2D Array to CSV file in PHP - String Error
I am trying to export a 2D array into a CSV file. This should be simple... but I tried every fputcsv example I could find and nothing works. Either the entire array is deposited into one row... Or when I try to insert via a foreach loop or I…

nodoze
- 127
- 1
- 14
-1
votes
1 answer
Fatal error: Cannot redeclare fputcsv()
I have found a php inventory http://inventory-management.org/ easy but was written in PHP4? and I run now on PHP5. I have found some errors that I have already managed to fix but they are keep coming up so I would like to see if I can managed to…

user3319377
- 15
- 1
- 8