I have text files that I would like to read into a website and then display. I use
$sListText = file_get_contents("result - 0001.txt");
echo nl2br($sListText);
which loads it fine with line breaks. I just have no clue how to turn the table data into a table with php.
The text file looks like this:
Prestige Byeenkoms 2014 Dal Josafat Stadion, 10/02/2014
Item: 1 (Dogters - 14) Spiesgooi 500 gm
Pos Naam Van Span Uitslag Punt ASA Rek
1 Marle Rademan GHBH 35.67 8 879 R
2 Lara Jordaan GHBH 25.58 5 671
3 Martine Hartung PG 24.67 4 650
4 Marlie Theunissen PG 23.50 3 622
5 Rochelle ROOS BLRO 21.75 2 578
6 Mishka ELLIS BLRO 21.20 1 564
The top two lines at the top are the headings. The data underneath must form a table with no border.
Can anyone please help?
Update:
I tried the following and it worked beautifully:
echo "<html><body><table>\n\n";
$f = fopen("0001.csv", "r");
while (($line = fgetcsv($f)) !== false) {
echo "<tr>";
foreach ($line as $cell) {
echo "<td>" . htmlspecialchars($cell) . "</td>";
}
echo "</tr>\n";
}
fclose($f);
echo "\n</table></body></html>";
Is it possible to skip the first two lines of the csv file, or better still, keep them separate from the table data which starts on line three?