Jump to content

Create table from .txt file?


Munch

Recommended Posts

Hi guys,

 

I am trying to get a php script to create a table from a .txt file that contains the following text:

 

00001,EGBB,EHAM,0930,1010,BA46,2x,90v$

 

I would like to make a table that looks something like this

 

| Flight No | From | To    | ETD  | ETA  | Aircraft | SR | Ticket |

---------------------------------------------------------------     

| 00001    | EGBB| EHAM | 0930 | 1010 | BA46    | 2x | 90v$    |

 

(The text file contains flight plan infomation from a virtual airline, this is downloaded every time a new flight plan is added then uploaded to my ftp site. this text file could end up holding 100+ lines of text)

 

Can anyone help me out with this please?

I think ive given you all the info you might need but if you need anymore infomation just ask :)

 

Thanks

Chris

Link to comment
https://forums.phpfreaks.com/topic/37721-create-table-from-txt-file/
Share on other sites

do this:

<table>
<?php
$data = file("filename.txt");
foreach ($data as $info) {
$pieces = explode(",", $info);
echo "<tr><td>".$pieces[0]."</td><td>".$pieces[1]."</td><td>".$pieces[2]."</td><td>".$pieces[3]."</td><td>".$pieces[4]."</td><td>".$pieces[5]."</td><td>".$pieces[6]."</td><td>".$pieces[7]."</td></tr>";}
?>
</table>

btw, is this some kind of game? i am really interested in it.

Ted

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.