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;
	}
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;
	}
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 ; }
Inserts values by interpreting tablular array as is typically the result
of a SQL call. If the table is nonstandard you can provide an idkey and
titlekey to help the function retrieve the correct values.

Typically defaults for idkey and title key are "id" and "title."

If groupkey is provided the method will insert optgroups instead of
normal options, unless the value for the group is null.

@return static $this
Inserts values by interpreting tablular array as is typically the result of a SQL call . If the table is nonstandard you can provide an idkey and titlekey to help the function retrieve the correct values .