Opening and reading files doesn't seem so difficult. I've seen several good examples out there. I've been attempting to play with putting a text file into a tabular format in a browser. I've figured out adding new table rows, but separating the columns into new table cells is eluding me!
Here's what I've done so far:
<?
$filename = "file.txt"; // choose file
$fd = fopen ($filename, "r"); // open the file to be read
$contents = fread ($fd,filesize ($filename)); // put the readable file into $contents
fclose ($fd); // close the file after opening it for browser
$delimiter_new_row = "\n"; // choose a new line delimiter
$splitcontents_new_row = explode($delimiter_new_row, $contents); // put
$counter = "";
?>
<font color="blue" face="arial" size="4">Complete File Contents</font>
<hr>
<?= $contents; ?>
<br>
<br>
<font color="blue" face="arial" size="4">Split File Contents</font>
<hr>
<table width="100%" border="1">
<? // here we determine the number of <tr><td> ?>
<? foreach ( $splitcontents_new_row as $ROWS_IN_FILE ){
$counter = $counter+1;
?>
<tr><td><?= $counter . " ". $ROWS_IN_FILE; ?></td></tr>
<? } ?>
</table>
This reads my file just fine, and puts it into a nice table with 1 column. The multiple rows are working.
Any idea on how to get the columns to show properly?