I have a script that I've written, that takes a CSV file, does some stuff, and then spits it back out as a tab delimited text file. After a few days of the file going wonky on me, I realized that one of the fields (at least one, maybe more, but I think just one) could contain commas. Ugh. So now, I need to figure out how to change this stuff around, so that it it looks for encapsulated fields and does the same stuff as before.
Here is just a snippet of the code -- I can handle implementing whatever the fix is, into the rest of the code. This particular snippet existed so that it would replace values of "+" with the appropriate invoice number. Then I go back later and run through the file again, having set this initial invoice number.
Nonetheless, here's the code:
Code: Select all
$customerData=fgets($handleReadCA);
$temp=explode(",",$customerData);
$invoiceNum=$temp[0];
$value=implode("\t",$temp);
fputs($handleWriteCA, $value);