I needed a way to include a bunch of files into my scripts without typing include "file"; each and every time I added something new to the folder so I came up with the below code which may be helpful to some:
CODE
$path_to_includes = "includes/";
$dir_handle = @opendir($path_to_includes) or die("Unable to open $path_to_includes");
$files = array();
while ($file = readdir($dir_handle))
{
$files[] = "$file";
include "$file";
} // end while loop
It's rather small and simple. Basically, we specify a directory to open and then open it for reading with @opendir($path_to_includes); The next step is to create an array $files = array(); then loop through the directory with while($file = readdir($dir_handle)). While looping, we place each file we run across in the array $files[] = "$file"; and then include them in our script with include "$file";
May not be the best way to go sometimes but can be very useful to those who don't want to retype include all the time.