W
W
Wayder2019-07-14 18:24:21
PHP
Wayder, 2019-07-14 18:24:21

How to add multiple lines to csv file?

Parsing I get data from the site.
for() - product pages
foreach() - for each product separately
In foreach I open a file
I create an array with column headings.
And then you need to add the lines themselves.
How can I add more?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2019-07-14
@Stalker_RED

fputcsv()

E
Evgeny Matveev, 2019-07-15
@ematveev

1) you can convert an array with product properties to a string:
$strTovar = implode("\t", $arrayTovar);
2) if there are several products, then we create an array of strings, let's say $arrayVseTovary, where such strings will be placed,
3) then we convert this array into one common string:
$strVseTovary = implode("\r\n", $arrayVseTovary);
4) after that, just write the $strVseTovary string to the CSV file, for example, using file_put_contents()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question