onlyican Posted December 10, 2006 Share Posted December 10, 2006 Hey guysI am building a Custom error LoggerSo I can do better quiries on it, I am adding it to a csvbutSome errors are MySQL Errors, which have commasand as CSV should do, it puts a coma as a new cellI tried replacing the commas with \,but it just adds a slashthen puts it in a new cellanyone know a way round this Link to comment https://forums.phpfreaks.com/topic/30124-problem-writing-to-csv/ Share on other sites More sharing options...
paul2463 Posted December 10, 2006 Share Posted December 10, 2006 Hi this might be a simple solution but you could write a quick function to iterate over the text changing all commas to another symbol not found in a sentence such as "~" . write the csv file then, when you pull the csv file run a reverse function on it, or it could be one function:-[code]<?php$ans = preg_replace(',', '~', $text);?>[/code]over simplified solution but it just might work Link to comment https://forums.phpfreaks.com/topic/30124-problem-writing-to-csv/#findComment-138483 Share on other sites More sharing options...
kenrbnsn Posted December 10, 2006 Share Posted December 10, 2006 How are you using the CSV file? Via PHP? If so, take a look at the [url=http://www.php.net/fgetcsv]fgetcsv()[/url] function. This function has an option which lets you tell it a quote character so commas between the quotes are ignored.Ken Link to comment https://forums.phpfreaks.com/topic/30124-problem-writing-to-csv/#findComment-138484 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.