<?php
$new_line = 'ID, Category, Description'."\n";
$file = 'dtifeed.csv';
$old_lines = file($file);
array_unshift($old_lines,$new_line);
$new_content = join('',$old_lines);
$fp = fopen($file,'r+');
$write = fwrite($fp, $new_content);
fclose($fp);
foreach($old_lines as $line)
{
$newstring = str_replace(',,,', ',', $line);
//process the string
}
$row = 1;
$handle = fopen("dtifeed.csv", "r+");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
?>