[nycphp-talk] Simple parse/replace
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Wed Sep 10 19:34:38 EDT 2003
On Wed, 10 Sep 2003, Robert Dumas wrote:
> What I want to do is output it in a nice table, with the tabs replaced with
> table cells. How would I parse it as such? Bear in mind that the text files
> must remain tab-delimited, so as not to boff up an analysis script, so I
> can't output table data into the text file (nor would I want to, if I could;
> that is far too kludgy).
This should be enough to get you started:
$fp = fopen('foo.tab', 'r');
print "<table>\n";
while ($line = fgetcsv($fp, 1000, "\t")) {
print " <tr>\n <td>";
print join("</td>\n <td>", $line);
print "</td>\n </tr>\n";
}
print "</table>\n";
fclose($fp);
-adam
--
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!
More information about the talk
mailing list