Untitled


SUBMITTED BY: Guest

DATE: Jan. 29, 2014, 5:18 a.m.

FORMAT: Text only

SIZE: 1.2 kB

HITS: 1149

  1. <?php
  2. //require('classes/ParseCSV.class.php');
  3. //$process_csv = new ParseCSV('andersons_bay_sample.csv');
  4. //$process_csv->processData();
  5. function readCSV($csvFile){
  6. $file_handle = fopen($csvFile, 'r');
  7. while (!feof($file_handle) ) {
  8. $line_of_text[] = fgetcsv($file_handle, 1024);
  9. }
  10. fclose($file_handle);
  11. return $line_of_text;
  12. }
  13. $csvArray = readCSV('andersons_bay_sample.csv');
  14. echo "<table style='border:1px solid black'>";
  15. for($i = 0; $i < count($csvArray); $i++)
  16. {
  17. echo "<tr>";
  18. for($j = 0; $j < count($csvArray[0]); $j++)
  19. {
  20. if($i == 0)
  21. {
  22. if($csvArray[0][$j] == "Date" || $csvArray[0][$j] == "Time")
  23. {
  24. echo "<th style='text-align:left;'></th>";
  25. }
  26. else
  27. {
  28. echo "<th style='text-align:left;'>" . $csvArray[0][$j] . "</th>";
  29. }
  30. }
  31. else
  32. {
  33. if($csvArray[$i][$j] == null)
  34. {
  35. echo "";
  36. }
  37. else
  38. {
  39. echo "<td style='border:1px solid black; padding:6px;'>" . $csvArray[$i][$j] . "</td>";
  40. }
  41. }
  42. }
  43. echo "</tr>";
  44. }
  45. echo "</table>";
  46. ?>

comments powered by Disqus