简体   繁体   中英

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 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.)

在PHP中,使用fgetcsv()读取CSV文件,忽略所需的列,然后使用fputcsv()写回CSV文件。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM