function _webform_select_options_to_text in Webform 7.4
Same name and namespace in other branches
- 6.3 components/select.inc \_webform_select_options_to_text()
- 7.3 components/select.inc \_webform_select_options_to_text()
Convert an array of options into text.
1 call to _webform_select_options_to_text()
- webform_select_options_ajax in components/
select.inc - Menu callback; Return a predefined list of select options as JSON.
File
- components/
select.inc, line 1062 - Webform module multiple select component.
Code
function _webform_select_options_to_text($options) {
$output = '';
$previous_key = FALSE;
foreach ($options as $key => $value) {
// Convert groups.
if (is_array($value)) {
$output .= '<' . $key . '>' . "\n";
foreach ($value as $subkey => $subvalue) {
$output .= $subkey . '|' . $subvalue . "\n";
}
$previous_key = $key;
}
else {
// Exit out of any groups.
if (isset($options[$previous_key]) && is_array($options[$previous_key])) {
$output .= "<>\n";
}
// Skip empty rows.
if ($options[$key] !== '') {
$output .= $key . '|' . $value . "\n";
}
$previous_key = $key;
}
}
return $output;
}