问题
Does anyone know of an online CSV editor written in PHP that will allow a user to open, edit, and save a given CSV file?
All I can find are CSV classes and nothing that can handle dynamic files, just predefined lengths etc.
回答1:
Parse the CSV file into array. Then, use an array of arrays to populate a matrix of text boxes in your web page. When you submit the form, read the data from $_POST and use fputcsv() to save it.
Think about validation, if relevant.
回答2:
So you want to be able to open a file, edit it using a web based UI and save it? Why not use Google Docs?
EDIT: Its irritating when people vote you down without leaving a comment as to why... Useless contributions...
回答3:
fgetcsv would solve your issue. Basically it takes in CSV file and parses it out into an array.
回答4:
http://www.phpclasses.org/package/2124-PHP-Retrieve-or-change-information-stored-in-CSV-files.html
Point it at a csv, tell it the delimiter, unique field and tell it to edit. Very simple to use. I've had an issue with the delete button but I only just tried it for the first time, I'm sure I can work that out.
Saved me some hours trying to build and test my own.
Edit: Worked out the issue with the unique column (or KeyFieldName as he calls it) don't have spaces in the name of that column (the first row of the csv)
来源:https://stackoverflow.com/questions/1191459/php-based-csv-editor