diff options
author | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2014-02-14 10:59:05 +0100 |
---|---|---|
committer | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2014-02-14 13:14:36 +0100 |
commit | 061a4d28bb6f889e9c6ff00aaf616e889026517c (patch) | |
tree | 7b369dd05fa28b621c5b996dbffcb0f0467cdd87 /examples/extract.php | |
parent | cfc39411c0645fe782803254cedd682d7fdc494f (diff) | |
download | csv-061a4d28bb6f889e9c6ff00aaf616e889026517c.zip csv-061a4d28bb6f889e9c6ff00aaf616e889026517c.tar.gz csv-061a4d28bb6f889e9c6ff00aaf616e889026517c.tar.bz2 |
Documentation Update
Diffstat (limited to 'examples/extract.php')
-rw-r--r-- | examples/extract.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/examples/extract.php b/examples/extract.php new file mode 100644 index 0000000..9e884fa --- /dev/null +++ b/examples/extract.php @@ -0,0 +1,44 @@ +<?php + +use Bakame\Csv\Reader; + +require '../vendor/autoload.php'; + +$inputCsv = new Reader('data/prenoms.csv'); +$inputCsv->setDelimiter(';'); +$inputCsv->setEncoding("iso-8859-15"); + +//get the header +$headers = $inputCsv->fetchOne(0); + +//get at maximum 25 rows starting from the second 801th row +$res = $inputCsv->setOffset(800)->setLimit(25)->fetchAll(); +?> +<!doctype html> +<html lang="fr"> +<head> + <meta charset="<?=$inputCsv->getEncoding()?>"> + <title>\Bakame\Csv\Reader simple usage</title> + <link rel="stylesheet" href="example.css"> +</head> +<body> +<h1>\Bakame\Csv\Reader simple usage</h1> +<table class="table-csv-data"> +<caption>Part of the CSV from the 801th row with at most 25 rows</caption> +<thead> + <tr> + <th><?=implode('</th>'.PHP_EOL.'<th>', $headers), '</th>', PHP_EOL; ?> + </tr> +</thead> +<tbody> +<?php foreach ($res as $row) : ?> + <tr> + <td><?=implode('</td>'.PHP_EOL.'<td>', $row), '</td>', PHP_EOL; ?> + </tr> + <?php +endforeach; +?> +</tbody> +</table> +</body> +</html> |