Download the PHP package yidas/csv without Composer
On this page you can find all versions of the php package yidas/csv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package csv
Short Description PHP CSV writer & reader with settings of quoting enclosure and encoding
License MIT
Homepage https://github.com/yidas/csv-php
Informations about the package csv
PHP CSV
PHP CSV writer & reader with settings of quoting enclosure and encoding
Features
-
Support generating Double Quotes enclosure for all entities setting
-
Support Encoding setting for local dialect
- Elegent Interface for setup and use
OUTLINE
- Demonstration
- Requirements
- Installation
- Usage
- Options
- Writer
- Reader
- Exceptions
- References
DEMONSTRATION
Quickstart with specifying the file name directly:
Write to CSV
Open a file and use libray to write in CSV format:
The content of generated CSV file will be:
In default setting, it will always add double quotes with
UTF-8
encoding.
Read from CSV
Open a CSV file with local encoding (Big5
) and use libray to read with UTF-8
encoding:
REQUIREMENTS
This library requires the following:
- PHP CLI 5.4.0+
INSTALLATION
Run Composer in your project:
composer require yidas/csv
Then you could use the class after Composer is loaded on your PHP project:
USAGE
Options
The options in parameter 2 for Writer/Reader class are as below:
quoteAll
Controls when quotes should be always generated by the writer.
Encoding
Controls which the encoding should be generated by the writer/reader.
By defaule, Microsoft Excel will open CSV file with local encoding. For example: Excel in Chinese(Traditional) Windows will open CSV with Big5 encoding.
Writer
writeRow()
Write the row parameter to the writer’s file stream, formatted according to the current setting.
writeRows()
Write the rows parameter to the writer’s file stream, formatted according to the current setting.
Reader
readRow()
Read a row from current file pointer.
Example:
readRows()
Read all the rows from current file pointer.
Example: