Files
parsecsv-for-php/examples/basic.php
Christian Bläul 387a0f5761 Renamed class to follow the PHP community guidelines such as:
- https://svn.apache.org/repos/asf/shindig/attic/php/docs/style-guide.html:
  "Acryonyms are treated as normal words."

- https://softwareengineering.stackexchange.com/a/149321/80632
  Overview of class naming conventions of PHP frameworks

- https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md
  No .lib allowed: "The class name corresponds to a file name ending in .php"

See issue #50
2018-02-02 13:22:58 +01:00

57 lines
1.1 KiB
PHP

<pre>
<?php
# include parseCSV class.
require_once('../ParseCsvForPhp.php');
# create new parseCSV object.
$csv = new ParseCsvForPhp();
# Parse '_books.csv' using automatic delimiter detection...
$csv->auto('_books.csv');
# ...or if you know the delimiter, set the delimiter character
# if its not the default comma...
// $csv->delimiter = "\t"; # tab delimited
# ...and then use the parse() function.
// $csv->parse('_books.csv');
# Output result.
// print_r($csv->data);
?>
</pre>
<style type="text/css" media="screen">
table {
background-color: #BBB;
}
th {
background-color: #EEE;
}
td {
background-color: #FFF;
}
</style>
<table border="0" cellspacing="1" cellpadding="3">
<tr>
<?php foreach ($csv->titles as $value): ?>
<th><?php echo $value; ?></th>
<?php endforeach; ?>
</tr>
<?php foreach ($csv->data as $key => $row): ?>
<tr>
<?php foreach ($row as $value): ?>
<td><?php echo $value; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>