Solved

Reading TEXT data from URL

Posted on 2006-11-19
2
193 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
2 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 230 total points
Comment Utility
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
Comment Utility
that's what I want ! Thanks :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now