[thelist] Displaying a txt file with PHP

Gustavo Arizpe garizpe at network.com.mx
Sat Oct 6 01:38:09 CDT 2001


First of all, I'd like to thank Artlung Joe for his answer when I asked for
a simple way to display CSV files with PHP. He suggested fgetcsv(), which is
a PHP function that really rocks! And it's probably not so widely used, as I
see MySQL used everywhere, even for very small projects.

Now I'd like to ask what is probably one of the most extended uses of PHP:
How can I display a .txt file using PHP? Let's say I have a text file,
filled with paragraphs of text.

How can I parse them using PHP, enveloping the paragraphs with <p>...</p>?
The url would be something like
http://mysite.com/file.php?parsedfile.txt

It would be even better to have the url like this
http://mysite.com/parsedfile.php , where the php script would be reading
parsedfile.txt, and generating the html from itself, without using
arguments.

I know for sure that this is a very simple thing to do (like the csv thing),
but that's probably the reason why I can't seem to find how to do it. All I
find are are more or less complex content management systems that really are
out what I'm trying to do, which is display the file, properly formatted.

Thanks so much,


Gustavo
http://www.area.com.mx





More information about the thelist mailing list