Solved

Reading TEXT data from URL

Posted on 2006-11-19
2
231 Views
Last Modified: 2008-03-06
Hi,

I want to store my data in a text file and put it in an URL, something like this:

http://www.myserver.com/data.txt

In the data.txt I will put something like this:

product1
height:10
width:20
color:blue

product2
height:22
width:40
color:red

How can I read that content of data.txt from a PHP page?

For example, I have this PHP page:

http://www.product1.com/display.php

This display.php will "generate" a web page and I need to get the content of that data.txt as part of the display.php content.

Anyone can help?

And what would be the best data structure? XML? I dont know how to read it btw :(

Thanks.

PS: I dont want to use database (MySQL, etc.).
0
Comment
Question by:klompen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 230 total points
ID: 17974776
You can open files from URLs the same way you can open files on the server itself:

<?php
$contents = file('http://www.myserver.com/data.txt');
print_r($contents);
?>


XML is probably better than a flat text format.  Here's PHP's extension for parsing XML: http://us3.php.net/xml

There are a number of other parsers out there that you can use on their own.
0
 

Author Comment

by:klompen
ID: 17974991
that's what I want ! Thanks :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question