From 2af3482ecfcd0e5672091f2be054baaeee604439 Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 18 Dec 2007 19:52:13 +0000 Subject: [PATCH] - Also quote a field if it contains a newline. --- lcsv.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lcsv.php b/lcsv.php index 7e52e0f..8ffd5d2 100644 --- a/lcsv.php +++ b/lcsv.php @@ -75,8 +75,12 @@ class lcsv { for($c=0;$c<$table_cols;$c++) { + $quote = false; //if the data contains the separator, we need to puti the data inside ""'s - if(strstr($dataline[$c],$this->separator())) + if(strstr($dataline[$c],$this->separator())) $quote = true; + /* If it contains a newline, also quote it */ + if(strchr($dataline[$c], "\n")) $quote = true; + if($quote == true) $this->csvdata.="\"".$dataline[$c]."\""; else $this->csvdata.=$dataline[$c];