irm-1.6-b3/lib/Savant2/Savant2_Plugin_options.php
/**
	*
	* Outputs a series of HTML <option>s.
	* 
	* Outputs a series of HTML <option>s based on an associative array
	* where the key is the option value and the value is the option
	* label. You can pass a "selected" value as well to tell the
	* function which option value(s) should be marked as selected.
	* 
	* @access public
	* 
	* @param array $options An associative array of key-value pairs; the
	* key is the option value, the value is the option label.
	* 
	* @param string|array $selected A string or array that matches one
	* or more option values, to tell the function what options should be
	* marked as selected.  Defaults to an empty array.
	* 
	* @param string|array $attr Extra attributes to apply to the option
	* tag.  If a string, they are added as-is; if an array, the key is
	* the attribute name and the value is the attribute value.
	* 
	* @return string A set of HTML <option> tags.
	* 
	*/
Outputs a series of HTML s.

Outputs a series of HTML s based on an associative array
where the key is the option value and the value is the option
label. You can pass a "selected" value as well to tell the
function which option value(s) should be marked as selected.

@access public

@param array $options An associative array of key-value pairs; the
key is the option value, the value is the option label.

@param string|array $selected A string or array that matches one
or more option values, to tell the function what options should be
marked as selected.  Defaults to an empty array.

@param string|array $attr Extra attributes to apply to the option
tag.  If a string, they are added as-is; if an array, the key is
the attribute name and the value is the attribute value.

@return string A set of HTML  tags.
Outputs a series of HTML s . Outputs a series of HTML s based on an associative array where the key is the option value and the value is the option label . You can pass a " selected " value as well to tell the function which option value ( s ) should be marked as selected . @access public @param array $options An associative array of key - value pairs ; the key is the option value the value is the option label . @param string|array $selected A string or array that matches one or more option values to tell the function what options should be marked as selected . Defaults to an empty array . @param string|array $attr Extra attributes to apply to the option tag . If a string they are added as - is ; if an array the key is the attribute name and the value is the attribute value . @return string A set of HTML tags .
function plugin($options, $selected = array(), $attr = null,
		$labelIsValue = false)
	{
		$html = '';
		settype($selected, 'array');
		settype($options, 'array');
		foreach ($options as $value => $label) {
						if ($labelIsValue) {
				$value = $label;
			}
			$html .= '<option value="' . htmlspecialchars($value) . '"';
			$html .= ' label="' . htmlspecialchars($label) . '"';
						if (in_array($value, $selected)) {
				$html .= ' selected="selected"';
			}
						if (is_array($attr)) {
				foreach ($attr as $key => $val) {
					$val = htmlspecialchars($val);
					$html .= " $key=\"$val\"";
				}
			} elseif (! is_null($attr)) {
				$html .= ' ' . $attr;
			}
			$html .= '>' . htmlspecialchars($label) . "</option>\n";
		}
		return $html;
	}
function plugin ( $ options , $ selected = array ( ) , $ attr = null , $ labelIsValue = false ) { $ html = '' ; settype ( $ selected , 'array' ) ; settype ( $ options , 'array' ) ; foreach ( $ options as $ value => $ label ) { if ( $ labelIsValue ) { $ value = $ label ; } $ html .= '<option value="' . htmlspecialchars ( $ value ) . '"' ; $ html .= ' label="' . htmlspecialchars ( $ label ) . '"' ; if ( in_array ( $ value , $ selected ) ) { $ html .= ' selected="selected"' ; } if ( is_array ( $ attr ) ) { foreach ( $ attr as $ key => $ val ) { $ val = htmlspecialchars ( $ val ) ; $ html .= " $ key = \" $ val \" " ; } } elseif ( ! is_null ( $ attr ) ) { $ html .= ' ' . $ attr ; } $ html .= '>' . htmlspecialchars ( $ label ) . " </option> \n " ; } return $ html ; }
Outputs a series of HTML <option>s.
Outputs a series of HTML <option > s .
// force $selected to be an array.  this allows multi-selects to // have multiple selected options. // loop through the options array // is the label being used as the value?
 // set the value and label in the tag // is the option one of the selected values?
 // are we adding extra attributes?
 // yes, from an array // yes, from a string // add the label and close the tag