beebosoft Posted April 18, 2009 Share Posted April 18, 2009 I have a database which holds records one fields of which holds the address of a client. I need to on a regular basis download this from the site as presferable a csv file. My problem is that some of the addresses have been entered with commas between the elements. when i down load the csv file it is not all set out neatly because of the extra commas. Does anyone have an idea of how i can get round this? Thanks in anticipation Angie Link to comment https://forums.phpfreaks.com/topic/154684-writing-to-csv-problem/ Share on other sites More sharing options...
soak Posted April 18, 2009 Share Posted April 18, 2009 You need to quote those fields. You could use fputcsv to write the csv file which would take care of this for you. Link to comment https://forums.phpfreaks.com/topic/154684-writing-to-csv-problem/#findComment-813413 Share on other sites More sharing options...
beebosoft Posted April 18, 2009 Author Share Posted April 18, 2009 I tested the fputcsv. It split each part up on the line. What i want is to ignore the commas in that field so the address is all in one field. should i try writing to a different type of file or should i try not letting commas be put into the address field? Angie Link to comment https://forums.phpfreaks.com/topic/154684-writing-to-csv-problem/#findComment-813426 Share on other sites More sharing options...
soak Posted April 18, 2009 Share Posted April 18, 2009 fputcsv will output something that can be opened in ms excel. If you really need to remove the comma's then just use: str_replace(',', '', $field) Link to comment https://forums.phpfreaks.com/topic/154684-writing-to-csv-problem/#findComment-813439 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.