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]
334 questions
-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,648
- 1
- 35
- 64
-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
- 9
- 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
- 7
-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,472
- 5
- 38
- 81
-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
- 3
-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
- 2,900
- 10
- 30
- 66
-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,275
- 3
- 20
- 40
-1
votes
1 answer
How to create a CSV download in Php
I need some help guys. I am pulling data from a CRM using API and I am looping through each variable eg. This is inside of Wordpress. The Answer below does work perfectly fine when isolated.
for ($x = 0; $x<=$total_leads; $x++){
$first_name =…
Brent Morse
- 19
- 3
-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
- 13
-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
-1
votes
4 answers
Save a .csv file to desktop
I am developing a script using PHP to
save a file to desktop as .csv file.
I found this code sample from PHP Manual.
user1427195
- 43
- 3
- 10
-1
votes
2 answers
CSV file contain double entries PHP SQL SERVER
I am using a solution from this SO question to make a user download a csv file. However my CSV output contains double entries for each output e.g if expected output is 1,2,3,4,5 I get 1,1,2,2,3,3,4,4,5,5.
My query is okay since it outputs the…
MaxI
- 763
- 2
- 10
- 43
-2
votes
1 answer
PHP Access objects and store it in an array or access objects as arrays?
I'm currently working on a project where I have to access the objects from Audience Segments and export the data that comes together with it in an excel format.
I'm still new to PHP and I can't seem to figure my way around this. Here's a sample…
oracle02
- 55
- 1
- 10