Hi, I am using a flatfile in a project i am working with but just have a little question which hopefully someone can help with. This is my code to display the items: <? $Lines = file("database.db"); foreach($Lines as $Key => $Val) { //explode that data into a new array: $Data[$Key] = explode("||", $Val); } for($K = 0; $K < sizeof($Lines); $K++) { echo "".$Data[$K][1]."<br>"; echo "".$Data[$K][2]."<br>"; } ?> Code (markup): Which is fine and works but i want this to display last entry first. Also it is outputting the entry like so: Entry 1|Entry 2 what i want it to do it in place of the | use a BR tag to make entry 2 below entry 1 without the | Cheers, Adam
This will reverse the line order: $Lines = array_reverse(file("database.db")); PHP: As for the other change, try this: echo '<table>'; for($K = 0; $K < sizeof($Lines); $K++) { echo "<tr>\n"; echo '<td>' . $Data[$K][1] . '</td>'; echo '<td>' . $Data[$K][2] . '</td>'; echo "</tr>\n"; } echo "</table>\n"; PHP: Untested, but give it a try. EDIT: I did just read your post again, and I'm not sure if I understood your second question right...
Hi, Thanks that worked fine. What i was refering to was when the array is echo'd it dispays the information like e.g. title|description. When it what i want it to do is title<br>description Cheers, Adam