Generates the set of option tags for an HTML select.
Notes:
- This method supports some more advanced options setups, which are used heavily by some of the MasterPress field types. This method can get a little complex, and this method should only really be used when you need to generate an HTML string to return to another piece of code, as MasterPress frequently needs to do. If you’re just outputting HTML, it would be more concise to echo the dynamic parts within standard HTML code.
- If a value in the $options array is an array itself, it is assumed then an optgroup will be generated using the key of that value as the label.
- The 3rd parameter is used to attach attributes to each option.
- If attributes are needed in a option group value, you can split the value of each of the values in the option group into an associative array of options and option attributes (see example)
Parameters:
-
An array of keys and values to use. See the description and example for more details on the formats supported.
-
An array of selected values or a single selected value.
-
Array $options_attr
An array of attribute arrays to attach to each option item.