The following array is produced by converting xml to a array (using xml2array). However its not the exactly the right format I need for a optgroup in a Drupal 6 form.
Array (
[root] => Array ([attr] => Array ([id] => 1) [label] => Array ([value] => My Root)
[node] => Array (
[0] => Array ([attr] => Array([id] => 2) [label] => Array([value] => Category 1)
[node] => Array(
[0] => Array ([attr] => Array ([id] => 14) [label] => Array ([value] => Sub-Category 1))
[1] => Array([attr] => Array ([id] => 15) [label] => Array([value] => Sub-Category2))
I think the array has too be reduced to this format with id values intact for the sub-categories. However I can't confirm this with the drupal docs as they don't mention anything about assigning values to a option.
Array (
[Category 1] => Array(
[14] => Sub-Category 1
[15] => Sub-Category 2
)
)
So my questions are 1) is what is the correct array format for Drupal optgroups with my specified values and 2) how do I reduce my array to match?