So, you have a text file with tab delimited values, one row per line yes? --- <TABLE> <? $file = 'path/to/your/file.txt'; $fp = fopen ($file,"r"); $row = 0; while ($myrow = fgetcsv ($fp, 1000, "\t")) { echo "<TR>"; foreach($myrow as $k => $v) { if($row == 0) { $v = "<B>{$v}</B>"; } echo "<TD>{$v}</TD>"; } echo "</TR>\n"; $row++; } fclose ($fp); ?> </TABLE> ---
Notes: 1. untested code, but should be fine 2. if you're not using a tab to separate your column values, it won't work 3. I'm wrapping the first rows values in <B>tags</B> to give some sort of heading, hence the need for the $row++ stuff... 4. for more information on it all, check out all the functions used in the manual, in particular fgetcsv() Enjoy! Justin French on 09/09/02 4:29 PM, Peter ([EMAIL PROTECTED]) wrote: > Hi, > I have 'test_file.txt' with the contents: > > label1 label2 label3 comments > name1 name2 name3 > name4 name5 name6 This is a comment > ... > > How can I turn this into a table using PHP? > > > Thanks, > -Peter > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php