I need help with a script that updates the data in a field in a csv file. I use fgetcsv to pull the data from a csv file into an array. I update the field as needed and then try to write the file back using fputcsv. For some reason the script cannot write the array back to the csv file. Here is my code:
$fp = fopen($target_path, "r+");
while ($line = fgetcsv($fp)) {
$myinput8 = $line[8];
$sqldate=date('Y-m-d',strtotime($myinput8));
$line[8] = $sqldate;
}
fputcsv($fp, $line) or die ("Cannot write to file.");
fclose($fp);
Thanks for looking,
Bob