public function webform_exporter_delimited::add_row in Webform 7.3
Same name and namespace in other branches
- 5.2 webform_export.inc \webform_exporter_delimited::add_row()
- 6.3 includes/webform.export.inc \webform_exporter_delimited::add_row()
- 6.2 webform_export.inc \webform_exporter_delimited::add_row()
- 7.4 includes/exporters/webform_exporter_delimited.inc \webform_exporter_delimited::add_row()
Overrides webform_exporter::add_row
File
- includes/
webform.export.inc, line 161 - Provides several different handlers for exporting webform results.
Class
Code
public function add_row(&$file_handle, $data) {
foreach ($data as $key => $value) {
// Escape inner quotes and wrap all contents in new quotes.
$data[$key] = '"' . str_replace('"', '""', $data[$key]) . '"';
// Remove <script> tags, which mysteriously cause Excel not to import.
$data[$key] = preg_replace('!<(/?script.*?)>!', '[$1]', $data[$key]);
}
$row = implode($this->delimiter, $data) . "\n";
if (function_exists('mb_convert_encoding')) {
$row = mb_convert_encoding($row, 'UTF-16LE', 'UTF-8');
}
@fwrite($file_handle, $row);
}