apple123 Posted June 2, 2008 Share Posted June 2, 2008 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] Link to comment https://forums.phpfreaks.com/topic/108443-formatting-a-text-file-into-a-html-table/ Share on other sites More sharing options...
cheechm Posted June 2, 2008 Share Posted June 2, 2008 Maybe if you post the code that generates it, it would be possible to generate it in the text file in a table format then you could just include it? Link to comment https://forums.phpfreaks.com/topic/108443-formatting-a-text-file-into-a-html-table/#findComment-555952 Share on other sites More sharing options...
metrostars Posted June 2, 2008 Share Posted June 2, 2008 IF you know the exact width of the colums in number of characters you could do some string manipulation and put it into an array. The only problem is that if the width of the column changes, you'll have to do it a different way Link to comment https://forums.phpfreaks.com/topic/108443-formatting-a-text-file-into-a-html-table/#findComment-555958 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.