Can I read a file in a directory?

robertdn

Moderator
How is everybody today?

I need your advice. I have about 700 files located in a directory named “Batch” and I need to read every file in this directory.

My question is, how do I go about reading each file?

Thank you for your aid.
 

HansM

New Member
There are a number of options available for you depending upon the programming language you are familiar with.

Personally, I would use the following code. I hope it helps or gives you a guideline to what to look for:

Code:
foreach (scandir(".") as $file) {
if (is_file($file)) {
function_name(file_get_contents($file));
}
}
 
Top