D
D
dimavfox2019-07-14 23:00:50
PHP
dimavfox, 2019-07-14 23:00:50

How to write multiple lines to csv file?

for ($k=1; $k <= 2; $k++) { 
    $res = $curl->get('');
    foreach ($products as $product) {
                 


                $list = array(
        'Строка для заголовков столбцов',
        'Делаю строку используя добытые данные\переменные для записи'
      );

      $fp = fopen('import.csv', 'w');

      foreach ($list as $line) {
        fputcsv($fp, explode(',', $line), ";");
      }
      
      fclose($fp);
}
}

This is the construction I use to parse goods.
Inside the foreach is all the data.
And inside the foreach I write the data to the file, but only one line is written, but 14 are needed (Because there are 14 products) How can I make sure that all lines are written?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question