PHP Code
 function DirList ($Dir, $Match = null) {
		/*
		Purpose
			Used to get a list of files in a directory matching a specified regular expression.
		Parameters
			Dir (String) = The directory we're working with.
			Match (Optional String) = A regular expression used to match file names.
		Return (Array)
			Returns a list of all files in the specified directory (Dir) that match the specified expression (Match).
			The . and .. files are never included in the returned list.
			Returns false if:
				- The specified directory (Dir) does not exist.
				- The specified regular expression (Match) is invalid.
		Version History
			1.0 2012.01.01 Tested by Russ Tanner - russtanner.com
		*/

		$r = array();									   // Return buffer

		$hFile = opendir($Dir);							 // Open the specified directory
		if ($hFile === false) return false;				 // Error Trap: The specified dir is invalid, return false

		while ($FileName = readdir($hFile)) {			   // Main loop: Read all files in the specified directory

			if ($FileName != '.' && $FileName != '..') {	// Skip the files "." and ".."
				$x = preg_match($Match, $FileName);		 // Test the current file against the regexp
				if ($x === false) return false;			 // Error Trap: The specified regular expression is invalid
				if ($x == 1) $r[] = $FileName;			  // The regexp matches the file name, append it to the return buffer
			}
		}

		closedir($hFile);								   // Clean up
		return $r;										  // Return the resulting array.

	} 
 


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)