ocd Posted February 23, 2010 Share Posted February 23, 2010 The goal of this file is to read in from a text file that has entered information from a forum in the following format. Male:Yes:No:School: Female:No:No:Work: Male:Yes:Yes:Student: Each time a user clicks submit on the survery, a new line is added to the text file using another PHP program that I understand and therefore omitted. I need to take the information in the text file above and present it on a webpage in a nice table... with "Number (1-15)" before it on the same <tr> but not <td>. My code below basically prints one long table with all the information and question numbers that go on forever. I know why this happens in terms of the code, but I just don't know how to stop the code after each line of reading from the text file, so that a new table can be made. Can anyone help me with this? I greatly appreciate it! Thank you. <?php $page = file_get_contents('./output.txt'); $tok = strtok($page, ":"); $i = 1; echo "<table border=1>"; while ($tok) { echo "<tr><td>Number $i</td>"; echo "<td>$tok\n</td></tr>"; $i++; $tok = strtok(":\r\n"); } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/193069-reading-a-text-file/ Share on other sites More sharing options...
ocd Posted February 23, 2010 Author Share Posted February 23, 2010 I figured it out myself. Used file() to create an array. Link to comment https://forums.phpfreaks.com/topic/193069-reading-a-text-file/#findComment-1016841 Share on other sites More sharing options...
jay7981 Posted February 23, 2010 Share Posted February 23, 2010 if working please click solved. Link to comment https://forums.phpfreaks.com/topic/193069-reading-a-text-file/#findComment-1016865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.