使用Medoo當高級選擇像這樣:CSV從嵌套陣列
$medoo->query('SQL Goes HERE')->fetchAll();
結果列於下面的結構中返回:
Array (
[0] => Array (
[Column 0 name] => "VALUE OF Record 0, Column 0"
[0] => "VALUE OF Record 0, Column 0"
[Column 1 name] => "VALUE OF Record 0, Column 1"
[1] => "VALUE OF Record 0, Column 1"
...
...
[Column 99 name] => "VALUE OF Record 0, Column 99"
[99] => "VALUE OF Record 0, Column 99"
)
[1] => Array (
[Column 0 name] => "VALUE OF Record 1, Column 0"
[0] => "VALUE OF Record 1, Column 0"
[Column 1 name] => "VALUE OF Record 1, Column 1"
[1] => "VALUE OF Record 1, Column 1"
...
...
[Column 99 name] => "VALUE OF Record 1, Column 99"
[99] => "VALUE OF Record 1, Column 99"
)
...
...
...
[99] => Array (
[Column 0 name] => "VALUE OF Record 99, Column 0"
[0] => "VALUE OF Record 99, Column 0"
[Column 1 name] => "VALUE OF Record 99, Column 1"
[1] => "VALUE OF Record 99, Column 1"
...
...
[Column 99 name] => "VALUE OF Record 99, Column 99"
[99] => "VALUE OF Record 99, Column 99"
)
)
每個陣列具有兩個締合鍵和和索引鍵值對出於某種原因,不是100%爲什麼他們這樣構建它。有關如何刪除所有索引結果並僅保留關聯數組的任何建議?
與PDO嘗試'$行= $ stmt->取(PDO :: FETCH_ASSOC );'儘管我沒有看到你的查詢在哪裏,所以只是猜測你使用的驅動程序。 – ArtisticPhoenix
'我不知道如何fputcsv實際上工作,當涉及到多維數組',據我所知,它不應該,你應該通過foreach循環頂層,並輸出'$行'文件。通常情況下,這是如何完成的。 – ArtisticPhoenix
我沒有使用PDO,我正在使用medoo:http://medoo.in – TheRealMrCrowley