Reading TEXT data from URL

Posted on 2006-11-19
Last Modified: 2008-03-06

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

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



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

For example, I have this PHP page:

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 :(


PS: I dont want to use database (MySQL, etc.).
Question by:klompen
LVL 19

Accepted Solution

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

$contents = file('');

XML is probably better than a flat text format.  Here's PHP's extension for parsing XML:

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

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hacked File Timestamps 4 50
how to handle $x_amount to payment gateway in php - stumped. 14 14
using php variable inside javascript 5 15
Scope of $_SESSION 17 30
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 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

13 Experts available now in Live!

Get 1:1 Help Now