How to overwrite information in a CSV file using PHP with the second line?

Hi all. I have a CSV file in the first line - I always have to have a name field.
When updating the page data in the file are overwritten but the first row always remains intact. How do I implement it? fseek - there bytes. I have failed to do. file_put_contents - it does not overwrite the data but adds to the end - it turns out that data is duplicated.
$fp = fopen('read.csv', 'w');
foreach ($new as $newone) {
$finish = array($newone[1],$newone[2]);
 fputcsv($fp, $finish);
June 8th 19 at 16:58
3 answers
June 8th 19 at 17:00
To put in the file in addition to data the first line of the headers is not the answer?
if you override the document - it is removed - brett.Simonis59 commented on June 8th 19 at 17:03
talking about that on every write to put the first row headers. - Clovis commented on June 8th 19 at 17:06
Yes, I want. But when you rewrite, the first line is overwritten - brett.Simonis59 commented on June 8th 19 at 17:09
When overwriting overwrite? - Clovis commented on June 8th 19 at 17:12
June 8th 19 at 17:02
When overwriting just this first line, first write down the problem each time to overwrite the file from scratch with this first line - it's static
June 8th 19 at 17:04
Try this:
$file = '/path/to/file/file_name';
$string = 'Here is a constant string, which should always be first';
file_put_contents($file, $string); //Creates or overwrites the file
foreach ($new as $newone) {
 $string = $newone;
 file_put_contents($file, $string, FILE_APPEND | LOCK_EX); //will Add line to the file

Find more questions by tags PHPCSV