forked from science-ation/science-ation
escape " with ""
This commit is contained in:
parent
d2a785acfb
commit
2539a1726f
16
lcsv.php
16
lcsv.php
@ -69,21 +69,21 @@ class lcsv
|
|||||||
}
|
}
|
||||||
|
|
||||||
//now do the data in the table
|
//now do the data in the table
|
||||||
if($table['data'])
|
if($table['data']) {
|
||||||
{
|
foreach($table['data'] AS $dataline) {
|
||||||
foreach($table['data'] AS $dataline)
|
for($c=0;$c<$table_cols;$c++) {
|
||||||
{
|
|
||||||
for($c=0;$c<$table_cols;$c++)
|
|
||||||
{
|
|
||||||
$quote = false;
|
$quote = false;
|
||||||
//if the data contains the separator, we need to puti the data inside ""'s
|
//if the data contains the separator, we need to puti the data inside ""'s
|
||||||
if(strstr($dataline[$c],$this->separator())) $quote = true;
|
if(strstr($dataline[$c],$this->separator())) $quote = true;
|
||||||
/* If it contains a newline, also quote it */
|
/* If it contains a newline, also quote it */
|
||||||
if(strchr($dataline[$c], "\n")) $quote = true;
|
if(strchr($dataline[$c], "\n")) $quote = true;
|
||||||
|
|
||||||
|
//escape a single " with ""
|
||||||
|
$dataline_c=str_replace('"','""',$dataline[$c]);
|
||||||
if($quote == true)
|
if($quote == true)
|
||||||
$this->csvdata.="\"".$dataline[$c]."\"";
|
$this->csvdata.="\"".$dataline_c."\"";
|
||||||
else
|
else
|
||||||
$this->csvdata.=$dataline[$c];
|
$this->csvdata.=$dataline_c;
|
||||||
|
|
||||||
if($c<$table_cols-1)
|
if($c<$table_cols-1)
|
||||||
$this->csvdata.=$this->separator();
|
$this->csvdata.=$this->separator();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user