Documentation
This commit is contained in:
parent
db680faa97
commit
ae1176ce78
44
README.md
44
README.md
|
@ -14,8 +14,7 @@ Or in your composer.json:
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
[...]
|
"deblan/csv": "~2"
|
||||||
"deblan/csv": "dev-master"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -29,22 +28,41 @@ use Deblan\Csv\Csv;
|
||||||
|
|
||||||
$csv = new Csv();
|
$csv = new Csv();
|
||||||
|
|
||||||
$csv->addLine(array('Foo', '$1000'));
|
// Defines the delimiter (default is ;)
|
||||||
$csv->addLine(array('Bar', '$600'));
|
$csv->setDelimiter(";");
|
||||||
|
|
||||||
$result = $csv->compile();
|
// Defines the enclosure (default is ")
|
||||||
```
|
$csv->setEnclosure('"');
|
||||||
|
|
||||||
```php
|
// Defines the end of line (default is \n)
|
||||||
use Deblan\Csv\Csv;
|
$csv->setEndOfLine("\n");
|
||||||
|
|
||||||
$csv = new Csv();
|
// Defines the charset (default is UTF-8)
|
||||||
|
$csv->setCharset("UTF-8");
|
||||||
|
|
||||||
$csv->setLegend(array('product name', 'price'));
|
// Add a new line at the end
|
||||||
$csv->addLine(array('Foo', '$1000'));
|
$csv->addData(['Foo', '$1000'));
|
||||||
$csv->addLine(array('Bar', '$600'));
|
|
||||||
|
|
||||||
$csv->compileToFile('products.csv');
|
// Add a new line at the end
|
||||||
|
$csv->appendData(['Bar', '$600']);
|
||||||
|
|
||||||
|
// Add a new line at the beginning
|
||||||
|
$csv->prependData(['Boo', '$3000']);
|
||||||
|
|
||||||
|
// Defines all the datas
|
||||||
|
$csv->setDatas([[...], [...]]);
|
||||||
|
|
||||||
|
// Defines the header
|
||||||
|
$csv->setHeaders(["Product", "Price"]);
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
$result = $csv->render();
|
||||||
|
|
||||||
|
// Rendering to a file
|
||||||
|
$result = $csv->render("products.csv");
|
||||||
|
|
||||||
|
// Appending to a file
|
||||||
|
$result = $csv->render("products.csv", FILE_APPEND);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parser
|
### Parser
|
||||||
|
|
Loading…
Reference in a new issue