使用PHP将文本解析为CSV文件

时间:2014-03-12 09:39:50

标签: php csv export-to-csv fputcsv

3 个答案:

答案 0 :(得分:1)

为什么你在PHP方面做这个呢?

SELECT * INTO OUTFILE "c:/mydata.csv"
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY "\n"
FROM my_table;

(the documentation for this is here)

答案 1 :(得分:0)

$output = array($row->fornamn . " " . $row->efternamn . " " . $row->personnr . " " . $row->gatuadress . " " . $row->postnr . " " . $row->postadress, ''

应替换为

$output = array($row->fornamn, $row->efternamn, $row->personnr, $row->gatuadress, $row->postnr, $row->postadress)

答案 2 :(得分:0)

$fp = fopen("filename.csv","w"); $value = array($var1,$var2,$var3); fputcsv($fp,$value,"\t");