note 36235 added to function.fgetcsv
| From: | mjwilco at yahoo dot com | Date: | Thu, 02 Oct 2003 00:35:26 +0000 |
| Subject: | note 36235 added to function.fgetcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57566@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36235
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36235&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36235&report=yes