B
B
BonBon Slick2016-09-02 16:24:02
PHP
BonBon Slick, 2016-09-02 16:24:02

How to add data to .CSV file?

Here is this line, enters. Since I have dynamic data there, it overwrites them, but I need something to append to the existing ones.

$list = array ( $my_data );
  $fp = fopen('parsed_data.csv', 'w');
  fputcsv($fp, $list);
  fclose($fp);

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Immortal_pony, 2016-09-02
@BonBonSlick

Use stream access type "a" instead of "w":
Read more about options

O
Oleg Mifle, 2016-09-02
@OlegMifle

You can use file_put_contents , for example.

C
crazyhat, 2016-09-02
@crazyhat

$fp = fopen('parsed_data.csv', 'a');
php.net/manual/en/function.fopen.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question