mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 00:36:38 +00:00
This is primarily a bug-fix release for a critical bug which was brought to my attention. - Fixed a critical bug in conditions parsing which would generate corrupt matching patterns causing the condition(s) to not work at all in some situations. - Fixed a small code error which would cause PHP to generate a invalid offset notice when zero length values were fed into the unparse() method to generate CSV data from an array. git-svn-id: http://parsecsv-for-php.googlecode.com/svn/trunk@22 339761fc-0c37-0410-822d-8b8cac1f6a97
49 lines
986 B
PHP
49 lines
986 B
PHP
<pre>
|
|
<?php
|
|
|
|
|
|
# include parseCSV class.
|
|
require_once('../parsecsv.lib.php');
|
|
|
|
|
|
# create new parseCSV object.
|
|
$csv = new parseCSV();
|
|
|
|
|
|
# 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>
|