1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<?php jj_readcsv('test.csv',true); function jj_readcsv($filename, $header=false) { $handle = fopen($filename, "r"); echo '<table>'; //display header row if true if ($header) { $csvcontents = fgetcsv($handle); echo '<tr>'; foreach ($csvcontents as $headercolumn) { echo "<th>$headercolumn</th>"; } echo '</tr>'; } // displaying contents while ($csvcontents = fgetcsv($handle)) { echo '<tr>'; foreach ($csvcontents as $column) { echo "<td>$column</td>"; } echo '</tr>'; } echo '</table>'; fclose($handle); } ?> |
