I am using PHP to pull data from a text file that is updated on a regular basis by a client. My code looks like this:

<?

$array = file('training.txt');
foreach($array as $row) {
$line = explode(',', $row);

print "<tr bgcolor=\"#eeeeee\">";
print "<td nowrap><font size=2 color=\"#666666\" face=\"Verdana, Arial, Helvetica, sans-serif\">$line[0]</font></td>";
print "<td nowrap><font size=2 color=\"#666666\" face=\"Verdana, Arial, Helvetica, sans-serif\">$line[1] EST</font></td>";
print "<td nowrap width=\"100%\"><font size=2 color=\"#666666\" face=\"Verdana, Arial, Helvetica, sans-serif\"><a href=\"javascript:Start('$line[3]')\";><b>$line[2]</b></a></font></td>";
print "<td nowrap><font size=2 color=\"#666666\" face=\"Verdana, Arial, Helvetica, sans-serif\"><a target=\"new\" href=\"$line[4]\">Register Now</a> </font></td>";
print "</tr>";

}
?>

The only problem is that the client is unable to produce a text file without an end-of-file-marker (hex 1A), so my code is reading the last line of the file and generating an unnecessary table row. Is there an easy way for me to ignore the EOF in the text file?

    does a regular expression search for the EOF character work? you could try replacing it with a balnk string using ereg_replace

      Write a Reply...