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?
EDIT:
I came up with something like this:
<?
$expandables = array();
$expandables = scandir("expandables/");
$count = 0;
foreach($expandables as $expandable) {
if ($expandable != "." && $expandable != "..") {
$expandableCode = "expandables/" . $expandable . "/index.html";
// get value of index.html for select list
$expandableValue = file_get_contents($expandableCode);
// echo out options
echo "<option value='$expandableValue'>$expandable</option>";
}
}
?>
But this isn't exactly working correctly. Is there a way to dynamically fill in my textarea with the index.html contents once I select it from the selectbox?