Run script on multiple files

Hi, hoping you can help and this is just a noob question. I have a php script that runs through a text file and grabs various bits of data and puts them into various tables in a d/b (it’s the boxscore from a football game).

Currently I process the files by sending them through a web form using $_POST, I then take the posted file and use file() to get it into an array and then run through it from there.

Now that all works fine but I’ve got hundreds of these files to process and it will take ages to process them all, even though each one only takes about 5 seconds to process.

I’d like to add some code at the top of the script that reads the contents of a specified directory and then runs the rest of the script (i.e the bit that inputs the data into the d/b) on the found files.

Any ideas?



Don’t worry, worked it out, I did this:

$dir = "input/";
while ($file = readdir($rep)) {
 if($file != '..' && $file !='.' && $file !=''){

$line = file($dir.$file);



Maybe not that elegant but worked for me :)

Sponsor our Newsletter | Privacy Policy | Terms of Service