Read file structure into an array, but only specific files.
Posted
by
dmackerman
on Stack Overflow
See other posts from Stack Overflow
or by dmackerman
Published on 2011-01-11T18:40:34Z
Indexed on
2011/01/11
18:53 UTC
Read the original article
Hit count: 154
I have a directory structure that looks like this:
/expandables
- folder
- folder
- folder
- folder
- BannerInfo.txt
- index.html
Each one of the folder
has the same exact stucture. One file named BannerInfo.txt
and index.html
. There are about 250 of these folders if that matters.
I want to loop through these folders and store each of the index.html
files into an array. Inside of the index.html
file is just some simple HTML and Javascript of which I want to read into a string to be displayed later on.
I'm struggling with how to filter out only the index.html
file from the individual folders.
The purpose of this is because I want to randomly select an index.html file and put the contents into a textarea. I thought I could do a simple array_rand()
on the returned array and spit out the string.
Any ideas?
© Stack Overflow or respective owner