You are here

function _webform_csv_data_matrix in Webform Matrix Component 7.3

Same name and namespace in other branches
  1. 6 components/matrix.inc \_webform_csv_data_matrix()
  2. 7.4 components/matrix.inc \_webform_csv_data_matrix()
  3. 7 components/matrix.inc \_webform_csv_data_matrix()
  4. 7.2 components/matrix.inc \_webform_csv_data_matrix()

Implements _webform_csv_data_component().

File

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

Code

function _webform_csv_data_matrix($component, $export_options, $value) {
  if ($value[0]) {
    $value_array = _webform_matrix_component_array($value[0]);
    $sub_elements = $component['extra']['element'];
    $csv_array = array();
    if (empty($value_array)) {

      //Populate $csv_array with empty data to push cells out
      $count_elments = count($sub_elements);
      for ($i = 0; $i < $count_elments; $i++) {
        $csv_array[] = '';
      }
      return $csv_array;
    }

    //Return managable display array
    $display_array = _webform_display_array($sub_elements, $value_array);
    $reverse_array = _webform_matrix_component_array_reverse($display_array);
    foreach ($reverse_array as $value) {
      $csv_array[] = implode(" - ", $value);
    }
    return $csv_array;
  }
  else {
    return '';
  }
}