PHP Append Column to end of the CSV file
<p>I have a CSV file in the php server</p>

<p>Want to Add "h3" at the end and fill the row with data "data3"</p>

<p>here is the structure</p>

<pre><code>  H1      H2   (h3)
  XXX     XXX   data3
  xxx     xxx   data3
</code></pre>

<p>I am trying with the following code for a long time, havent get any luck yet</p>

<pre><code>&lt;?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);
?&gt;
</code></pre>

<p>Please advice</p>