N
N
NinjaSystems2021-07-08 22:05:02
PHP
NinjaSystems, 2021-07-08 22:05:02

How to write csv to 1 column?

I have a CSV file with multiple columns. I need to take data from it in one column and write it to a new csv file. The fputcsv() function takes an array. And how to write only lines?

$fp = fopen('content.csv', 'r');
$newCsv = fopen('new_content.csv', 'w');

while($data = fgetcsv($fp,0,';'))
{
    fputcsv($newCsv, $data[15], ';');
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Page-Audit.ru, 2021-07-09
@PageAuditRU

fputcsv($newCsv, [$data[15]], ';');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question