public static function rand($length, $charsets = array('alpha', 'number', 'symbol'))
	{
		$rand = '';
		
		// if $length and $charsets are given
		if ($length !== null && $charsets !== null) {
			// if $length is an integer
			if (is_numeric($length) && is_int(+$length)) {
				// if $charsets is a string or array
				if (is_string($charsets) || is_array($charsets)) {
					// if $charsets is a string, array-ify it
					if (is_string($charsets)) {
						$charsets = (array) $charsets;
					}

					// define the possible charsets
					$lower  = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 
						'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
					$upper  = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
						'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
					$number = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
					$symbol = array('!', '@', '#', '*', '(', ')', '-', '_', '+', '=', '[', ']');
			
					// create an array of possible chars
					$chars = array();
					foreach ($charsets as $charset) {
						if (isset($$charset)) {
							$chars = array_merge($chars, $$charset);
						} elseif ($charset === 'alpha') {
							$chars = array_merge($chars, $lower, $upper);
						} else {
							throw new \InvalidArgumentException(
								__METHOD__." expects parameter two to be a string charset name or an array ".
									"of charset names such as 'lower', 'upper', 'alpha', 'number', or 'symbol'"
							);
						}
					}
			
					// shuffle the chars
					shuffle($chars);
			
					// pick $length random chars
					for ($i = 0; $i < $length; ++$i) {
						$rand .= $chars[array_rand($chars)];
					}
				} else {
					throw new \InvalidArgumentException(
						__METHOD__." expects the second parameter, charsets, to be a string charset ".
							"name or an array of charset names"
					);
				}
			} else {
				throw new \InvalidArgumentException(
					__METHOD__." expects the first parameter, length, to be an integer"
				);
			}
		} else {
			throw new \BadMethodCallException(
				__METHOD__." expects at least one argument, length"
			);
		}

		return $rand;
	}