Using the following function I have placed all of the directories and files into an array. It's been quite a process to get this far(two days!). My experience and skill level end here and I have no direction in which to go. If someone could offer some direction I would greatly appreciate it.
Here is the function I have.
Code:
error_reporting(E_ALL);
global $array_items;
function get_dir_file_array($directory='.', $recursive= false, $include_directories_in_list = true) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory. "/" . $file)) {
if($recursive) {
$array_items = array_merge($array_items, get_dir_file_array($directory. "/" . $file, $recursive));
}
if ( $include_directories_in_list ) {
$file = $directory . "/" . $file;
print "<strong>$file</strong><br />\n";
$array_items[] = preg_replace("/\/\//si", "/", $file);
}
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
} else {
$file = $directory . "/" . $file;
print "<strong>$file</strong><br />\n";
$array_items[] = preg_replace("/\/\//si", "/", $file);
}
}
}
closedir($handle);
}
return $array_items;
}
$files = get_dir_file_array("f:/wamp/www/courses/contents/video-lectures", TRUE);
To work with the array I can use a foreach statement and it list all of my directories with the full path on one line and then all of the files within that directory on subsequent lines. There are 22 sub-directories.
I would like to target each of the sub-directories and then the index.htm file within that directory. Then using the file_get_contents function, I would like to loop through all of the index.htm files and pull content from them. The sub-directory names will be used as the title of a lesson.
This sounds like a lot to me but it may be simple for someone with a skill level far beyond mine.
Thanks again
Bookmarks