我需要将我具有的关联数组导出到.csv文件。我无法得出我需要的方式。
我这样做:
function array_to_csv_download($array, $filename = "Output.csv", $delimiter=";") {
$f = fopen($filename, 'w');
foreach ($array as $line) {
fputcsv($f, $line, $delimiter);
foreach ($line as $row) {
fputcsv($f, $row, $delimiter);
}
}
}
array_to_csv_download($AllItems);
结果:
"Phone Samsung Galaxy A50 4/64Gb SM-A505F/DS";phone;"LTE, 3G (UMTS), GSM 900, GSM 1800, GSM 1900";Android;"Android 9.0";"Exynos 9610"; ... etc.
我的数组:
array (
0 =>
array (
'Name' => 'Phone Samsung Galaxy A50 4/64Gb SM-A505F/DS',
'Type' => 'phone',
'Voice' => 'LTE, 3G (UMTS), GSM 900, GSM 1800, GSM 1900',
'Platform' => 'Android',
'OS' => 'Android 9.0',
'CPU' => 'Exynos 9610',
... etc.
),
1 =>
array ( ... ),
)
我如何在.csv中获得输出,如:
"Name":"Phone Samsung Galaxy A50 4/64Gb SM-A505F/DS";"Type":phone;"Voice":"LTE, 3G (UMTS), GSM 900, GSM 1800, GSM 1900" ... etc.
感谢帮助!