Strip quotes from fputcsv results.
For now, I'm querying a MySQL database with phpMyAdmin and exporting results to a comma delimited CSV file.
It works fine but I need to automate this if I can.
The php script I created uses fputcsv but by default it adds double quotes around text strings containing spaces.
And the service I'm working with doesn't allow quotes in the CSV file.
Results with fputcsv:
1234,"prod name with spaces",29.95,/path/filename.zip,1gb,4320
Desired result:
1234,prod name with spaces,29.95,/path/filename.zip,1gb,4320
<?php
mysqli_select_db($con, "myproducts") or die ("no database found");
$result = mysqli_query($con,"SELECT prodcode, prodname, price, dload_url, size, expiry_time FROM downloads WHERE dload_url LIKE '%value%' ORDER BY prodcode DESC");
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$fp = fopen('myfile.csv', 'w');
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
fputcsv($fp, $row);
}
fclose($fp);
?>
Any ideas?
Nancy O.
