summaryrefslogtreecommitdiffstats
path: root/examples/xml.php
diff options
context:
space:
mode:
authorignace nyamagana butera <nyamsprod@gmail.com>2015-12-11 10:28:14 +0100
committerignace nyamagana butera <nyamsprod@gmail.com>2015-12-11 10:28:14 +0100
commit0a1b535df48507f58ed3c7ab44e72272b11163ac (patch)
tree516c4f68d24eb0b10e47a6abfbbdca694b0dbfb8 /examples/xml.php
parent630f69081696cbb091338086724f809472a7ee79 (diff)
downloadcsv-0a1b535df48507f58ed3c7ab44e72272b11163ac.zip
csv-0a1b535df48507f58ed3c7ab44e72272b11163ac.tar.gz
csv-0a1b535df48507f58ed3c7ab44e72272b11163ac.tar.bz2
Update examples for version 8.08.0.0
Diffstat (limited to 'examples/xml.php')
-rwxr-xr-xexamples/xml.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/xml.php b/examples/xml.php
index 3104680..86b34c9 100755
--- a/examples/xml.php
+++ b/examples/xml.php
@@ -4,16 +4,17 @@ use League\Csv\Reader;
require '../vendor/autoload.php';
+ //we order the result according to the number of firstname given
+$func = function ($row1, $row2) {
+ return strcmp($row2[1], $row1[1]);
+};
+
$csv = Reader::createFromPath('data/prenoms.csv');
$csv->setEncodingFrom('ISO-8859-15');
-$csv->setFlags(SplFileObject::READ_AHEAD|SplFileObject::SKIP_EMPTY);
$csv->setDelimiter(';');
-//since version 7.0 only 10 rows will be converted using the query options
$csv->setOffset(1);
$csv->setLimit(10);
-$csv->addSortBy(function ($row1, $row2) {
- return strcmp($row2[1], $row1[1]); //we order the result according to the number of firstname given
-});
+$csv->addSortBy($func);
$doc = $csv->toXML('csv', 'ligne', 'cellule');
$xml = $doc->saveXML();
header('Content-Type: application/xml; charset="utf-8"');