Getting fputcsv to write a number as string for Excel
Posted: Fri Mar 10, 2006 9:17 pm
Hi
I have an $row that is an array. Im writing to a csv file which I opened in Excel. Problem is, that Excel is treating the Phone column as a number. So I did $row['Phone'] = '"'.$row['Phone'].'"';
But now fputcsv is entering it as
so in Excel it shows up as
But I want is
so that Excel will treat it as a string and not a string with double-quotes.
How to I 'tell' fgetcsv not enter 3 quotes but only 1 ?
Thanks
I have an $row that is an array. Im writing to a csv file which I opened in Excel. Problem is, that Excel is treating the Phone column as a number. So I did $row['Phone'] = '"'.$row['Phone'].'"';
Code: Select all
$row['Phone'] = '"'.$row['Phone'].'"';
fputcsv ($h, $row)."\n";Code: Select all
value5,"""56565656""",value7Code: Select all
value5,"56565656",value7Code: Select all
value5,"56565656",value7How to I 'tell' fgetcsv not enter 3 quotes but only 1 ?
Thanks