You are here

function matrix_select_option_from_text in Webform Matrix Component 7

Convert matrix select option values to options array.

5 calls to matrix_select_option_from_text()
webform_matrix_get_column_form in components/matrix.inc
Webform_edit_form extra form elements.
_webform_csv_data_matrix in components/matrix.inc
Implements _webform_csv_data_component().
_webform_display_matrix in components/matrix.inc
Implements _webform_display_component().
_webform_render_matrix in components/matrix.inc
Implements _webform_render_component().
_webform_table_matrix in components/matrix.inc
Implements _webform_table_component().

File

components/matrix.inc, line 760
Webform module matrix component.

Code

function matrix_select_option_from_text($options) {
  if ($options != '') {
    foreach (preg_split("/((\r?\n)|(\r\n?))/", $options) as $line) {
      if (strstr($line, '|')) {
        list($key, $value) = explode('|', $line);
      }
      else {
        $key = $value = $line;
      }
      $option_array[$key] = $value;
    }
  }
  $option_array = count($option_array) == 0 ? array(
    0 => 'None',
  ) : $option_array;
  return $option_array;
}