blob: ec07f8434b16e5681280ce93d934521361eeed6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
use League\Csv\Reader;
require '../vendor/autoload.php';
$inputCsv = Reader::createFromPath('data/prenoms.csv');
$inputCsv->setDelimiter(';');
//get the header
$headers = $inputCsv->fetchOne(0);
//get at maximum 25 rows starting from the 801st row
$res = $inputCsv->setOffset(800)->setLimit(25)->fetch();
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>League\Csv\Reader simple usage</title>
<link rel="stylesheet" href="example.css">
</head>
<body>
<h1>League\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>
|