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
vote
3 answers
PHP insert array values to csv column
I have a large (size ~ 12k) 2D array of data like below and I want to insert these data into a csv file.
$data = array
(
'a' => array
(
0 => 111,
1 => 222,
2 => 333,
3 => 444,
),
'b' => array
(
…

Arpit Jain
- 1,599
- 9
- 23
1
vote
1 answer
fputcsv generates line without newline
Here's code full code with removed SQL part. I expect it starts download CSV file with data from database. But when i foreach csv array, it unexpectedly prints all data in almost right format but ignores newlines and puts ' '(space) instead.
$csv =…

Nikita Cunskis
- 31
- 1
- 8
1
vote
0 answers
Generate and divide folders with file size limit
I am working on to extract pdf files from site to the FTP. Currently, all my files along with a index file with the names of the files extracted is being generated into one folder. I want to divide this folder into multiple folders. Each Folder will…

user6345655
- 57
- 4
1
vote
1 answer
How to convert Array to Array list for CSV export using FputCSV?
I need to convert an array with multiple results to a CSV file but am struggling to get a valid output .
After some debugging I realized I am not generating a valid array list for fputcsv to iterate through .
First of all, here is an illustrative…

Optimus Servers
- 47
- 8
1
vote
1 answer
This site can’t be reached error while using fputcsv in php
After file download code I am getting the error at XAMPP
This site can’t be reachedThe webpage at http://localhost/aiken/index.php/admin/view_download might be temporarily down or it may have moved permanently to a new web…

Farrukh K. Jadoon
- 21
- 4
1
vote
1 answer
PHP Wrap ALL fields in quotes fputcsv()
I'm relatively new to PHP so please bear with me.
my code currently looks like this:

Paul Shears
- 13
- 2
1
vote
1 answer
Writing in a file make my program load really slowly
I am trying to write csv files with fwrite/fputcsv in a loop but when I use those functions, they write in the first file and then the tab loads infinitely and doesn't do anything else.
I know those functions are the problem because when I remove…

R-son
- 65
- 10
1
vote
1 answer
How to concatenate two columns in a csv file in php?
I have a csv file like this:
I would like to concatenate the values of the style_color columns in this csv file. To have for example SCJEG4_1014.
I wrote a script, it creates this last column with the header 'Pictures Names' but in each cell I just…

Patrick62
- 71
- 8
1
vote
1 answer
PHP CSV merge two CSV files when there is same data in both files' rows
I have csv01 like that:
A | B | C | D
-----------------------------
905 | bla | meh? | na
16 | meh | meh? | ni
4 | bla | meh? | put
I have csv02 like that:
A | Z | Y
---------------------
4 | info…

mlclm
- 725
- 6
- 16
- 38
1
vote
1 answer
PHP MySQL query specific fields to CSV
I'm trying to make a CSV file out of my query result but I need to format the data first before writing it to the CSV.
I have a working code which prints the whole row to csv and is working fine.
header('Content-Type: text/csv; charset=utf-8'); …

iceman
- 31
- 5
1
vote
1 answer
How To write one column array to csv file
I am trying to write post variables to a csv file but it writes everything in one line separated by comma

Johan Venables
- 57
- 6
1
vote
1 answer
How save all the results of a php query to a .txt file?
My query gives me a result in an array :
$donnnes =
Table ( [0] => Table ( [sku_code] => A1101_0090_TU [SKU_EAN] => 9346799868270 ) )
My .txt file create itself well but fills up like this :
MMXC1_|9346799868270|0|0
MMXC1_| |0|1
MMXC1_|…
user12886630
1
vote
1 answer
Cannot write to my csv file from Oracle database using PHP
I think I used fputcsv correctly.My database table contains two columns with dates and numbers in both columns. I use an oracle database and a windows 2008 server.
//Connexion BDD Oracle
$connect = odbc_connect("oraclesrc", "xe", "sec123");
$query…

Theo27
- 385
- 4
- 17
1
vote
1 answer
Automatically add new rows with values to a csv file generated from mysql
i created a small script that i generating a csv file with a content from a mysql db. Everything is working fine but i am struggling with one issue... as you can see i am generating a file for a WooCommerce product import. My database contain's only…

Wojciech
- 103
- 1
- 3
- 12
1
vote
1 answer
PHP: How to optimise looping through a CSV and writing a line to a file dependent on value in column
I have the following code which takes a $filename and loops through it. If the 9th column is in an array of values (not shown here), I ignore it.
Otherwise I write the row to a file which name is based on the 3rd column.
if (($handle =…

pee2pee
- 3,619
- 7
- 52
- 133