Answer the question
In order to leave comments, you need to log in
How to edit a CSV file?
Good afternoon!
I use the standard function for writing to CSV
$list = array(
array('email', $dataS)
);
$fp = fopen('file.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
Answer the question
In order to leave comments, you need to log in
You have chosen the wrong mode with which you open the file, see the documentation:
php.net/manual/en/function.fopen.php
you need to specify the mode a instead of w :$fp = fopen('file.csv', 'a');
If you only need to append to a file, then open it with the a (append) parameter,fopen('file.csv', 'a')
php.net/manual/ru/function.fopen.php read about the mode parameter.
If you want to add exactly to the end of the file, then change 'w' to 'a'.
If you need to change lines inside, you will have to move the pointer manually php.net/manual/en/function.fseek.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question