[英]export the data from db with double quotes into csv in php
i have some data in mysql with double quotes.. when i export it into csv it doesn't support the double quotes.. Please help me.. 我在mysql中有一些双引号的数据..当我将其导出到csv时,它不支持双引号..请帮助我..
echo $csv_output="9"Strawberry; echo $ csv_output =“ 9”草莓;
in excel file it doesn't found 在Excel文件中找不到
You need to escape the double quotes. 您需要转义双引号。 You need to change a double quote to two double quotes.
您需要将双引号更改为两个双引号。
For example: 例如:
echo $csv_output="9"Strawberry;
would need to be: 将需要是:
echo $csv_output=str_replace('"','""','"9"Strawberry');
or even 甚至
echo $csv_output=str_replace('"','""',$value_from_db);
For more details, see: http://en.wikipedia.org/wiki/Comma-separated_values#Example 有关更多详细信息,请参见: http : //en.wikipedia.org/wiki/Comma-separated_values#Example
while exporting data to CSV file use following code to remove single quote . 将数据导出到CSV文件时,请使用以下代码删除单引号。
$value = str_replace( '"' , '""' , $value );
it will replace your single quote with double quote 它将用双引号替换您的单引号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.