用于修改csv文件条目的Php和javascript代码

I try to describe my complete situation...

I read a csv file using php function. I developed a php class that represent an entry of the file. So, I have a php array that contains all my entries. When I read all entries of the file, I use a php function to visualize these into a table. For the table I use jQuery tableSorter.

Now, the user can edit some rows of this table (for this I wrote some javascript functions). At this point I need to save (on the csv file) every modified table rows. Is there a simple way to make this?

Need I to modify the php array? Is possibile to modify a php variable by javascript code? Sorry but I'm new about this.

Practical examples are welcome.

No, you're not modifying the PHP Array. There are several ways to handle your request. You could use the input fields in your table to make a POST request and save the changes to your CSV file.

The more Javascript-ish way could be an AJAX Request which is fired on change of each field. Your Server / PHP-Code is accepting that request and writes only the data of that field.

In both cases you should know how to handle POST requests / forms in PHP. Submitting a form by POST generates a new PHP array, accessible as $_POST.

Practical examples are depending on the expected behavior. Using forms will reload the page on submitting. Using AJAX not. But the usage of AJAX (XMLHTTPRequest if you want to read some documentation) is a little tricky if you're new to Javascript

Link about XMLHTTPRequest (AJAX) http://www.w3schools.com/xml/xml_http.asp

Link about Form handling: http://www.w3schools.com/php/php_forms.asp