Questions tagged [fputcsv]

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.

354 questions
-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
  • 4
  • 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
  • 12
  • 43
-2
votes
1 answer

Add new row in CSV using PHP

I want to append form data in a CSV file that is stored on the server, the data should be added as a new row. I tried $list = array( 'Peter,Griffin,Oslo,Norway,Norway,Norway,Norway,Norway', …
Mukash Wasti
  • 135
  • 1
  • 16
-2
votes
1 answer

Write to CSV with PHP function fputcsv

I am using fputcsv to write to a CSV from MySQL results: $list = array("group, variable, value \r\n"); while ($row = mysqli_fetch_assoc($result)) { array_push($list, $row['strand_pk'] . ',' . $row['unit_name']. "\r\n"); } $fp =…
IlludiumPu36
  • 4,196
  • 10
  • 61
  • 100
-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
-2
votes
3 answers

Array into a CSV file using same id in PHP

I have an array called : $messages with this data. (Generated dynamically). How can I create a CSV file which contains 3 columns (txt, time and name) for each txt_id with the values ? array(3) { [0]=> array(5) { ["txt"]=> string(3)…
yuhell
  • 15
  • 4
-2
votes
2 answers

From CSV to array with headerkeys, now back to CSV

Our Story: (short version below if you're eager to troubleshoot) This question is asked after extensively searching for a way to get a multidimensional array (with named keys) back into it's CSV file. You might say: "But this is covered on multiple…
RkdL
  • 112
  • 11
-3
votes
1 answer

fputcsv - columns from table displayed in one column

I have a problem with putting data from mysql database to csv file. The column headers are ok but rest of rows from table are in one column. Please help..
Kermit
  • 49
  • 1
  • 8
-3
votes
1 answer

PHP Generated CSV File filled with html crap from webhost instead of data?

I am using PHP to generate a csv file with a first name and second name. On my local XAMPP server it works fine and generate this output. Andy,Murray Sarah,Palin Bob,Saget However on this 000webhost.com free webhosting site I get the following…
tomaytotomato
  • 3,788
  • 16
  • 64
  • 119
1 2 3
23
24