src/Common.php
final public static function check_dict(
		array $array, array $keys, bool $trim=false
	) {
		$checked = [];
		foreach ($keys as $key) {
			if (!isset($array[$key]))
				return false;
			$val = $array[$key];
			if ($trim) {
				if (!is_string($val))
					return false;
				$val = trim($val);
				if (!$val)
					return false;
			}
			$checked[$key] = $val;
		}
		return $checked;
	}
final public static function check_dict(
		array $array, array $keys, bool $trim=false
	) {
		$checked = [];
		foreach ($keys as $key) {
			if (!isset($array[$key]))
				return false;
			$val = $array[$key];
			if ($trim) {
				if (!is_string($val))
					return false;
				$val = trim($val);
				if (!$val)
					return false;
			}
			$checked[$key] = $val;
		}
		return $checked;
	}
final public static function check_dict ( array $ array , array $ keys , bool $ trim = false ) { $ checked = [ ] ; foreach ( $ keys as $ key ) { if ( ! isset ( $ array [ $ key ] ) ) return false ; $ val = $ array [ $ key ] ; if ( $ trim ) { if ( ! is_string ( $ val ) ) return false ; $ val = trim ( $ val ) ; if ( ! $ val ) return false ; } $ checked [ $ key ] = $ val ; } return $ checked ; }
Check if a dict contains all necessary keys.

@param array $array Dict to verify.
@param array $keys List of keys to verify against.
@param bool $trim Whether it should treat everything as string
and trim the values and drop keys of those with empty values.
@return bool|array False on failure, filtered dict otherwise.
Check if a dict contains all necessary keys .