开发者

How to remove columns from a csv file with PHP?

I know the names of the columns I want to keep in the .csv file, but I 开发者_StackOverflow中文版am interested in removing all columns in the .csv which I don't recognize. How can php do this?

(The names of the columns are defined in the first row of the file.)


In PHP use fgetcsv() to read in your CSV file, ignore the columns you want and then write back to a CSV file using fputcsv();


Look at fgetcsv and fputcsv. Read the contents, write the columns/data back out that you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜