I would suggest doing this by the way you pass an array to the function. Right now, it takes a single dimension array
Code: Select all
array(
[0] => Item One
[1] => Item Two
)
Code: Select all
array(
['Group One'] => array(
[0] => Item One
[1] => Item Two
)
['Group Two'] => array(
[2] => Item Three
[3] => Item Four
)
)
Code: Select all
<select>
<optgroup label="Group One">
<option value="0">Item One</option>
<option value="1">Item Two</option>
</optgroup>
<optgroup label="Group Two">
<option value="2">Item Three</option>
<option value="3">Item Four</option>
</optgroup>
</select>