function _webform_csv_data_grid in Webform 5
Same name and namespace in other branches
- 5.2 components/grid.inc \_webform_csv_data_grid()
- 6.3 components/grid.inc \_webform_csv_data_grid()
- 6.2 components/grid.inc \_webform_csv_data_grid()
- 7.4 components/grid.inc \_webform_csv_data_grid()
- 7.3 components/grid.inc \_webform_csv_data_grid()
Return the result of a textfield submission. The output of this function will be displayed under the "results" tab then "submissions".
Parameters
$data: An array of information containing the submission result, directly correlating to the webform_submitted_data database schema.
Return value
Textual output formatted for CSV, not including either prefixed or trailing commas.
File
- components/
grid.inc, line 345
Code
function _webform_csv_data_grid($data, $component) {
$rows = explode("\n", _webform_filtervalues($component['extra']['questions']));
$questions = array();
$cid = 0;
foreach ($rows as $row) {
$row = trim($row);
if (preg_match('/^([^"|]+)\\|(.*)$/', $row, $matches)) {
$questions[$matches[1]] = $matches[2];
}
else {
$questions[$cid++] = $row;
}
}
foreach ($questions as $item => $question) {
$output .= "\\," . $data['value'][$item];
}
// Remove the preceding extra comma
$output = substr($output, 2);
return $output;
}