PHP processes CSV tables, using fgetcsv and fputcsv to convert between arrays and CSV

Source: Internet
Author: User
PHP processes CSV tables, using fgetcsv and fputcsv to convert between arrays and CSV Array <= fgetcsv | fputcsv => csv

To edit an online Excel table, parsing the Excel xls file format is a problem. after all, this is the private patent format of Microsoft Office.
To do this, use the common csv (Comma Separated Value, Comma-Separated Value) format.
Various office software can recognize csv tables, which are actually tables separated by specific delimiters (such as commas.
For PHP, fgetcsv reads the csv table and returns an array,
Then foreach outputs










 
In this step, several lines of code can be implemented, which is very simple.The workload mainly lies in the browser front-end. we recommend that you use jQuery to perform DOM and AJAX operations,To achieve fine-grained double-click cell editing like phpMyAdmin, it is not difficult to submit AJAX,Or $ ("form"). serialize () once the entire table is written, and AJAX can also be submitted. CSV table rules:1. separate the content of cells in each row with commas.2. if the content of a cell contains a comma, the content of the cell will be enclosed in quotation marks.3. if the content of a cell contains quotation marks:The quotation marks are not at the beginning or end, and the content of this cell is not included in the quotation marks.The content of this cell is enclosed in quotation marks at the beginning or end, and the original quotation marks at the beginning and end are escaped.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.