PHP read file question

Associate
Joined
5 Feb 2006
Posts
129
Location
Birmingham
I am currently using this line of code:-

$fp = fopen ('pod.csv', 'r');

to read a csv file, my question is, is it possible to use a wild card in stead of a specific file name example *.pod???

The file name changes every day and i am sick of having to change it to pod so my script works! cheers!
 
Presuming there will only ever be one CSV file in the directory:

Code:
$files = glob('*.csv');

$fp = fopen($files[0], 'r');

Also, look at using fgetcsv if you're not already.
 
Back
Top Bottom