I have part of code that transmit values to CSV file but in UNIX LF. But I need Windows CR LF
function insert_data($columns, $elements) {
$elements_to_insert = count($elements);
$count = 0;
$message = sprintf($this->language->get('progress_export_elements_inserted'), 0, $elements_to_insert);
$this->update_process($message);
foreach ($elements as $element_id => $element) {
$temp = array();
foreach ($columns as $col_name => $col_info) {
$custom_name = $col_info['custom_name'];
$temp[] = array_key_exists($custom_name, $element) ? str_replace(array('\r', '\n', '/\s+/g', '/\t+/'), '', $element[$custom_name]) : '';
}
$this->writer->addRow($temp);
$count++;
$message = sprintf($this->language->get('progress_export_elements_inserted'), $count, $elements_to_insert);
$this->update_process($message, true);
}
$this->writer->close();
}
Various attempts to transfer data to Windows CR LF are unsuccessful. There were the following attempts:
str_replace(array('\r\n', '/\s+/g', '/\t+/')
str_replace(array('\r\n', '\n', '/\s+/g', '/\t+/')
str_replace(array("\r\n", '/\s+/g', '/\t+/')
str_replace(array("\r\n", "n", '/\s+/g', '/\t+/')
How can I make it?