note 36235 deleted from function.fgetcsv by felipe
| From: | felipe@php.net | Date: | Sun, 10 Feb 2008 13:32:50 +0000 |
| Subject: | note 36235 deleted from function.fgetcsv by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135980@lists.php.net to get a copy of this message | ||
Note Submitter: mjwilco at yahoo dot com
----
Here's one way to convert the data in a csv file to an html table:
<?php
$filename = "book1.csv"; //here's the filename
$id = fopen($filename, "r"); //open the file
while ($data = fgetcsv($id, filesize($filename))) //start a loop
$table[] = $data; //put each line into its own entry in the $table array
fclose($id); //close file
echo "<table>\n";
foreach($table as $row)
{
echo "<tr>";
foreach($row as $data)
echo "<td>$data</td>";
echo "</tr>\n";
}
echo "</table>\n";
?>
You may need to change the parameters for fgetcsv() to suit your needs and probably change the table
style.