summaryrefslogtreecommitdiffstats
path: root/examples/writing.php
diff options
context:
space:
mode:
authorIgnace Nyamagana Butera <nyamsprod@gmail.com>2014-02-14 10:59:05 +0100
committerIgnace Nyamagana Butera <nyamsprod@gmail.com>2014-02-14 13:14:36 +0100
commit061a4d28bb6f889e9c6ff00aaf616e889026517c (patch)
tree7b369dd05fa28b621c5b996dbffcb0f0467cdd87 /examples/writing.php
parentcfc39411c0645fe782803254cedd682d7fdc494f (diff)
downloadcsv-061a4d28bb6f889e9c6ff00aaf616e889026517c.zip
csv-061a4d28bb6f889e9c6ff00aaf616e889026517c.tar.gz
csv-061a4d28bb6f889e9c6ff00aaf616e889026517c.tar.bz2
Documentation Update
Diffstat (limited to 'examples/writing.php')
-rw-r--r--examples/writing.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/writing.php b/examples/writing.php
new file mode 100644
index 0000000..948008a
--- /dev/null
+++ b/examples/writing.php
@@ -0,0 +1,42 @@
+<?php
+
+use Bakame\Csv\Writer;
+
+require '../vendor/autoload.php';
+
+$writer = new Writer(new SplTempFileObject); //the CSV file will be created into a temporary File
+$writer->setDelimiter("\t"); //the delimiter will be the tab character
+$writer->setEncoding("utf-8");
+
+$headers = ["position" , "team", "played", "goals difference", "points"];
+$writer->insertOne($headers);
+
+$teams = [
+ [1, "Chelsea", 26, 27, 57],
+ [2, "Arsenal", 26, 22, 56],
+ [3, "Manchester City", 25, 41, 54],
+ [4, "Liverpool", 26, 34, 53],
+ [5, "Tottenham", 26, 4, 50],
+ [6, "Everton", 25, 11, 45],
+ [7, "Manchester United", 26, 10, 42],
+];
+
+$writer->insertAll($teams);
+?>
+<!doctype html>
+<html lang="fr">
+<head>
+ <meta charset="<?=$writer->getEncoding()?>">
+ <title>Using the \Bakame\Writer object</title>
+ <link rel="stylesheet" href="example.css">
+</head>
+<body>
+<h1>Example 4: Using Writer object</h1>
+<h3>The table representation of the csv</h3>
+<?=$writer->toHTML('table-csv-data with-header');?>
+<h3>The Raw CSV to be saved</h3>
+<pre>
+<?=$writer?>
+</pre>
+</body>
+</html>