Jump to content

Formatting a text file into a HTML table


apple123

Recommended Posts

I have a text file that is automatically generated from a script. The text file contains data in a table format (not a real table, just looks like a table with everything spaced out).

 

Check out the exampledata.txt file attached to this message to see an example of what I'm talking about.

 

I need to display this text on a HTML page in my PHP script; however, if I include the text file, the spaces aren't preserved. Also, I don't want to just display the raw text, I want to apply some formatting to it.

 

I want to put the text into a HTML table. The problem is that the number of spaces between the data is not consistent. I know that more spaces will be put between the column names to accomodate the data (so if a particular piece of data in a column is longer than the rest, it will put more spaces after all the data in that column to make it consistent). One space is inserted between the longest piece of data in one column and the start of the data in the next column.

 

Is there any way for me to put this into a HTML table?

 

(Also, the column names are not Column 1 and Column 2, they are something else, but not always one word. And the Data isn't Data1 either, it's something else, but not always one word.)

 

 

[attachment deleted by admin]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.