Reply to topic
import data from .txt
Groll


Joined: 23 Dec 2004
Posts: 27
Reply with quote
Anyone know how to import data into a web page from a space seperated .txt file that updates on a regular basis? Basically, i need the page to reference this .txt file on a daily basis and give me results looking similar to a database would on a page.
pmeserve
HostMySite Tech

Joined: 19 Mar 2004
Posts: 178
Reply with quote
Groll,

One easy way to get everything out of a file is the command file_get_contents. See:
http://us3.php.net/file_get_contents

This pulls everything into a string, from which you can do some parsing. If this isn't exactly what you want, check the left sidebar of links on that page - it has many other file functions, and there's almost certainly a combination you can find to do what you're looking for
plu


Joined: 03 May 2005
Posts: 27
Location: Philadelphia
Reply with quote
There are two things that need to be done:

1. Structure your text file as a delimited file format. You can use any special character as delimited characters, " | " will be good enough
2. Use spilt function to parse the text file and output results in your favorite format
import data from .txt
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic