Files_FromDirs() - Gets a list of files from a list of directories

PHP Code

function Files_FromDirs ($Dirs, $DirSep = null) {
	/*
	Purpose
		Used to get a list of files from a list of directories.
	Parameters
		Dirs (string) = A list of directories we will search.
		DirSep (optional string) = The directory separator used in each element of the directory list (Dirs).
			Default if null: DIRECTORY_SEPARATOR
			Default: null
	Return (string array)
		Returns a list of all files in all directories in the specified directory list (Dirs).
		Full file paths are returned.
		Returns false if:
			- Any specified directory (Dir) is invalid or inaccessible.
	Version History
		1.0	2015.05.14 Tested by Russ Tanner on PHP 5.6.8 Win 7-64.
	*/

	$r = array();

	// Iterate all specified directories.
	for ($i = 0; $i < count($Dirs); $i++) {
		// Get a list of files from the current directory.
		$x = Files_FromDir($Dirs[$i], $DirSep);
		// Error Trap: Invalid directory. Return false and exit now.
		if ($x === false) return false;
		// Merge the current directory with the return buffer.
		$r = array_merge($r, $x);
	}

	return $r;

}
 



The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)