我目前有一個查詢,返回下面的數組..當我嘗試將數據導出到CSV文件時,我看到數據兩次(列重複,而不是行)..可以有人向我解釋爲什麼? (我想有每個記錄顯示只有一次)PHP導出數組爲CSV
Array
(
[0] => Array
(
[0] => 6991
[id] => 6991
[1] => 8588
[work_num] => 8588
[2] => Test123
[name] => Test123
[3] => 1407154
[deployed] => 1407154
[4] => 2015-10-13
[created_date] => 2015-10-13
)
)
這是我使用。如果你正在使用MySQL的數據
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
// output the column headings
fputcsv($output, array('id','Work Number','Name','Deployed','Date'));
$get_data = $CLASSNAME->FuntionName(Parameters);
foreach($get_data as $data_row) {
fputcsv($output, $data_row);
}
fclose($output);
你的數據是作爲一個MySQL查詢結果。郵政編碼獲取數據。 –