protected function create_csv_file($records)
{
$header_data = current($records);
unset($header_data['attributes']);
$header = array_keys($header_data);
$file_data = '"' . join('";"', $header) . '"' . "\r\n";
foreach ($records as $record) {
$data = [];
unset($record['attributes']);
foreach ($record as $key => $value) {
if (!is_array($value)) {
$data [] = '"' . $value . '"';
}
}
$file_data .= join(";", $data) . "\r\n";
}
return $file_data;
}
伙计们,我有一个创建CSV文件的功能。
但是出于某种原因,CSV导出会运行到EOF中,因为某些列具有空格或在我用来包装数据单元格的文本(“或”)中使用相同的字符。
如何正确掩盖单元格以获取所有数据?
我想要:
第一个单元格,第二个单元格,第三个单元格
但是我明白了
第一,第二,第三,第三单元格
下面您将找到数组
Array
(
[0] => Array
(
[Name] => Peter
[Priority] => 3
[State] => false
[Message] =>
)
[1] => Array
(
[Name] => Anna
[Priority] => 4
[State] => false
[Message] =>
)
[2] => Array
(
[Name] => Jen
[Priority] => 1
[State] => true
[Description] => An: email@address.com
CC:
BCC:
Attachment: -- no Attachment --
Topic: How does it work?
Text:
description
)