function options_table(array $table, $valuekey = null, $labelkey = null, $groupkey = null) {
		$optgroups = [];
		$options = [];

		if ($groupkey === null) {
			$options = static::associativeFrom($table, $valuekey, $labelkey);
		}
		else { # got group key
			foreach ($table as $row) {
				if ($row[$groupkey] !== null) {
					isset($optgroups[$row[$groupkey]]) or $optgroups[$row[$groupkey]] = [];
					$optgroups[$row[$groupkey]][$row[$valuekey]] = $row[$labelkey];
				}
				else { # null group
					$options[$row[$valuekey]] = $row[$labelkey];
				}
			}
		}

		$this->options_array($options);
		$this->optgroups_array($optgroups);

		return $this;
	}