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
0
votes
0 answers
CSV file displaying value in different columns
I have an array $email_details and it is like this :
Array
(
[email_address] => myemailid@yahoo.com
[mail_client_friendly_name] => Apple iPhone iOS 7
)
I am trying to put this in CSV and doing the following code :
header("Content-type:…

Happy Coder
- 4,255
- 13
- 75
- 152
0
votes
1 answer
SimpleXML to CSV with missing tags
So I have an XML file that looks similar to this:
some text
some text
some text
some text
some…

Gixxy22
- 507
- 1
- 8
- 20
0
votes
1 answer
fputcsv writing to blank file
I am having some trouble exporting a CSV file using fputcsv. The file downloads but it is blank. I have tried exporting to xls and it works perfectly but I wanted to use csv with custom field headers as shown in code below. I am not sure if I am…

626
- 1,159
- 2
- 16
- 27
0
votes
1 answer
preg_split on fputcsv to store a array of elements into different columns of csv
I'm trying to store the values of the table in to a csv file for which I used fputcsv function. However it puts the elements into a single column. I need to store the values in three columns.
Code:
foreach ($total as $key => $value)
{
…

Krishna
- 97
- 9
0
votes
0 answers
power failure when using f_put_contents for large file
When using file_put_contents in for loop, I tried this
for(loop) {
file_put_contents("content ");
}
So if power failure occurs in middle of loop.
Some data should be written in the file.
But it is blank
I have the same problem with fputcsv()
I…

user2750711
- 3
- 1
0
votes
0 answers
fputcsv not writing array to csv file
I have a form on a website that a when a user submits will store their form details and then write it to a new line in an existing csv file.
I have got the code working correctly, allowed all permissions, and tested to see if the file exists (as…

James
- 2,800
- 7
- 45
- 81
0
votes
1 answer
fputcsv not exporting database into csv
Not outputting anything in csv file. Please help!!
This print_r($list).
outputs everything in the database in the right format But when i try to put the into a csv file only one line gets outputted.
$sql = "select * from " . TABLE_ORDERS . "";
…

user2531490
- 17
- 1
- 5
0
votes
1 answer
Memory leak while using fputcsv
I'm outputting a large csv file through standard output (php://output) by using the built-in fputcsv function, but I get a memory error after writing about 14000 lines.
I called ob_end_clean to not use the output buffer, but it doesn't work. Also, I…

Gonzalo
- 3,674
- 2
- 26
- 28
0
votes
3 answers
Alternative to fputcsv
I have an array that I want to export to a CSV file, now I know that there is a fputcsv function but I am using version 5.0.4 of PHP so this isn't an option for me.
Is there an alternative method I can use?

davemire
- 1
- 1
- 4
0
votes
1 answer
Non-ascii characters in fputcsv
So I have a simple script that writes some data to a CSV-file. The file contains a few non-ascii characters (norwegian characters) which are not displayed correctly in when opened in Excel. However they are displayed correctly in OpenOffice. Does…

Fredrik
- 1,741
- 4
- 24
- 40
0
votes
1 answer
Exporting to csv formatting issue
I'm trying to export some data into a csv file, I've got the data going into the file, this is my code:
*Please excuse me if the code is bad, I've never done anything like this and this was the only way I could get it working.
/* CSV Export -…

frankstuner
- 4,380
- 2
- 16
- 15
0
votes
2 answers
Change font style with fputcsv
I need to change the text of header from lighter to bold of the csv . I am using fputcsv() of php to generate to csv file.
fputcsv($output,array('Report','Entitlement Report'));
This is the basic code which I am using to print the header of my…

Anish
- 4,262
- 6
- 36
- 58
0
votes
1 answer
Download a CSV file on an external server
The code below works on my localhost test machine, but I need to know how to get it to work on an external server. I need to be able to download the .csv file. Is there a way I can prompt the user to download the file or do I have to choose a…

JimRomeFan
- 407
- 6
- 19
0
votes
1 answer
fputcsv exporting HTML when there isn't data to export
I have SQL query that exports data to a CSV.
All works well until I go below a certain amount of data in the export.
When I go below this threshold, the records are exported followed by the html of the page.
If I add more characters on the…

fairywings78
- 117
- 1
- 8
0
votes
1 answer
fputcsv fails if string to long
I'm trying to write to a csv file using fputcsv and it appears to be failing when the string is too long.
Does fputcsv have a limit when writing?

Brob
- 665
- 2
- 13
- 23