Get all option elements, including nested options, in a select.
$element: The element for which to get the options.
Option elements in select.
protected function getAllOptions(SimpleXMLElement $element) {
$options = array();
// Add all options items.
foreach ($element->option as $option) {
$options[] = $option;
}
// Search option group children.
if (isset($element->optgroup)) {
foreach ($element->optgroup as $group) {
$options = array_merge($options, $this
->getAllOptions($group));
}
}
return $options;
}