I am trying to extract data from a CSV, run a function on some of it and spit it out into a new CSV. I'm getting stuck and writing the data to an array properly. Also, the file is created but its empty.
PHP
$file = fopen("yahrzeit-3.csv","r");
if ($file) {
while ( ( $row = fgetcsv( $file, ";" ) ) !== false ) { // 3
$data .= array ( $row[2], $row[3], $row[6], $row[7], $row[8], $row[14] );
}
print_r($data);
$fp = fopen('mailchimp.csv', 'w');
foreach ($data as $fields) {
print $subfields;
fputcsv($fp, $fields);
}
fclose( $fh ); // 5
}
fclose($fp);