Defining and reading a file.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SkyFlyer
Forum Newbie
Posts: 7
Joined: Fri Jun 10, 2005 1:47 am

Defining and reading a file.

Post by SkyFlyer »

I am editing a script for a friend.

Code: Select all

<?php

$file1="1.txt"; //Text file for trial purposes... should be in the same directory as
$file2="2.txt";
How do I define the file to read the txt no matter what it is called? Such as a wild card.

$file1="*.txt"; Would this work?
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

you cannot read any file, that would be slightly strange.
I don't see why you would want that either.

If you want to read each file in a folder you have to get all the files in the folder, uhm can't remember the function for that right now.
Revan
Forum Commoner
Posts: 83
Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:

Post by Revan »

scandir();

array scandir ( string directory [, int sorting_order [, resource context]] )

then just remove the extra entrys with string functions.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

SkyFlyer
Forum Newbie
Posts: 7
Joined: Fri Jun 10, 2005 1:47 am

Post by SkyFlyer »

What the script is for is an online sports league. It reads text files, and uploads the information to a database. I can post the entire script if you wish. It is a little long, and like I said, I did not write it. I am only making modifications to it.


BTW thanks for helping on this :)
Post Reply