I have a CSV file in the php server
Want to Add "h3" at the end and fill the row with data "data3"
here is the structure
H1 H2 (h3)
XXX XXX data3
xxx xxx data3
I am trying with the following code for a long time, havent get any luck yet
<?php
$newCsvData = array();
if (($handle = fopen("file.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$data[] = 'report_type';
$newCsvData[] = $data;
}
fclose($handle);
}
$handle = fopen('test.csv', 'w');
foreach ($newCsvData as $line) {
fputcsv($handle, $line);
}
fclose($handle);
?>
Please advice